Commit 9305a9f9 authored by Your Name's avatar Your Name
Browse files

p9 / readme / autologin

parent 64168e28
Libvirt / kvm setup
What it does
- rootfs on lvm
- rootfs on p9
- setup networking (bridges, firewall, vm config)
- creates root filesystem with debootstrap and clones the puppet repo
- uses https://git.puscii.nl/puppet1/puppet-buildkernel to build kernels / initramfs (needs to get integrated nicely)
BUGS
- p9 atm. only works when qemu is running as root (you can change it in /etc/libvirt/qemu.conf)
- network config changes /etc/network/interfaces (a workaround is defining all netork interfaces in hiera as described here: https://github.com/example42/puppet-network#hiera-examples)
Example hiera:
````
"domain": "example.org",
"vms": {
"ldap": {
"dns": "1.1.1.1",
"external_gw": "192.168.185.1",
"external_ip": "192.168.185.10",
"external_net": "external",
"external_nm": "255.255.255.0",
"internal_gw": "192.168.23.1",
"internal_ip": "192.168.23.10",
"internal_net": "net-internal",
"internal_nm": "255.255.255.0",
"name": "ldap"
}
},
"networks": {
"external": {
"dns": "8.8.8.8",
"gateway": "192.168.185.1",
"netmask": "255.255.255.0",
"network": "192.168.185.0/24"
},
"net-internal": {
"dns": "1.1.1.1.1",
"gateway": "192.168.23.1",
"netmask": "255.255.255.0",
"network": "192.168.23.0/24"
}
},
......@@ -168,11 +168,8 @@ EOF
puppetfingerprint=`chroot ${MOUNTDIR} puppet agent --test --fingerprint | cut -d ' ' -f 2` || true
fi
# autologin on ttyS0
cat <<EOF > "${MOUNTDIR}/etc/systemd/system/serial-getty-autologin@.service"
# autologin getty
cat <<EOF > "${MOUNTDIR}/lib/systemd/system/serial-getty\@.service "
[Unit]
Description=Serial Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
......@@ -181,23 +178,14 @@ BindsTo=dev-%i.device
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service
[Service]
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty --autologin root -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM
ExecStart=-/sbin/agetty --autologin user --noclear --keep-baud 115200,38400,9600 %I $TERM
Type=idle
Restart=always
UtmpIdentifier=%I
......@@ -210,20 +198,12 @@ SendSIGHUP=yes
[Install]
WantedBy=getty.target
EOF
#autologin on serial console
if rm "${MOUNTDIR}/etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service"
then
echo "there was already a ttyS0 service"
fi
ln -s "/etc/systemd/system/serial-getty-autologin@.service" "${MOUNTDIR}/etc/systemd/system/getty.target.wants/serial-getty-autologin@ttyS0.service"
# enable console
chroot ${MOUNTDIR} systemctl enable serial-getty@ttyS0.service
sshfingerprint=`ssh-keygen -l -f ${MOUNTDIR}/etc/ssh/ssh_host_ed25519_key`
sshfingerprintrsa=`ssh-keygen -l -f ${MOUNTDIR}/etc/ssh/ssh_host_rsa_key`
......
......@@ -6,8 +6,8 @@ define hypervisor::vm::deploy (
$ensure = 'present',
String $domain = lookup('domain', undef, undef, 'nodomainset.la'),
Stdlib::Fqdn $public_hostname = "${name}.${domain}",
String $devices_profile = 'headless',
String $dom_profile = 'myprofile',
String $devices_profile = '9p',
String $dom_profile = '9p',
String $rootsize = '4G',
String $swapsize = '1G',
Boolean $datadisk = false,
......@@ -151,17 +151,30 @@ define hypervisor::vm::deploy (
audit => 'content',
notify => Exec["restart_${name}"],
}
$devices = undef
$disk = undef
if "${devices_profile}" == 'p9' {
notify { "prof is: $devices_profile": }
if "${devices_profile}" == '9p' {
notify { "we are using 9p: $devices_profile": }
file { "/srv/rootfs/${name}":
ensure => directory
}
mount { "/srv/rootfs/${name}":
ensure => 'mounted',
device => "/dev/${hypervisor::vm::root_vg}/${name}-disk"
ensure => 'mounted',
device => "/dev/${hypervisor::vm::root_vg}/${name}-disk",
fstype => "ext4"
}
$devices = { "filesystem" => { "values" => { "source" => { "attrs" => { "dir" => "/srv/rootfs/${name}" }}}} }
$devices = { "filesystem" => { "values" => {
"source" => { "attrs" => { "dir" => "/srv/rootfs/${name}" }},
"target" => { "attrs" => { "dir" => 'root9p' }}
}} }
$disks = undef
} else {
notify { "we are NOT using 9p: $devices_profile": }
$devices = undef
$disks = hypervisor_disks($name,$hypervisor::vm::root_vg,$hypervisor::vm::swap_vg,$hypervisor::vm::data_vg,$datadisk)
}
......
......@@ -5,8 +5,8 @@
class hypervisor::vms (
String $domain = lookup('domain', undef, undef, 'no_domain_set'),
$vm_defaults = {
devices_profile => 'headless',
dom_profile => 'myprofile',
devices_profile => '9p',
dom_profile => '9p',
}
......@@ -28,7 +28,16 @@ class hypervisor::vms (
kernel_type => 'debian',
}
buildkernel::kernel { 'p9':
kernel_version => '4.19.0-13-amd64',
kernel_type => 'debian',
}
file { "/srv/rootfs/":
ensure => directory
}
# create vm's defined in hiera
$vms = hiera_hash('vms')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment