Update cloud-init

* Update script to add all stuff from install_kvm into it, rather than
  runcmd.
* Update the virsh user as per the MAAS code
* Add support to add focal, only change of packages
This commit is contained in:
2020-12-28 11:12:50 +00:00
parent 53e4d3ae76
commit d5bb8a353c
2 changed files with 19 additions and 13 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
1. Add script to cloud-init, that will allow to wipe disk. This will allow to
reboot the hypervisor, such that we don't have to log back in after the
machine has been re-commissioned.
1. Update hypervisor config such that it works with focal
1. ~~Update hypervisor config such that it works with focal~~
1. Add the ability to add multiple storage pools (1 x SSD, 1 x HDD)
1. Update `boostrap-maas.sh`
1. Snap implementation
+18 -12
View File
@@ -15,16 +15,13 @@ users:
- name: virsh
lock_passwd: false
passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/
shell: "/bin/bash"
shell: "/bin/rbash"
## Install additional packages on first boot
packages:
- virtinst
- bc
- jq
- qemu-kvm
- libvirt-bin
- qemu-efi
- ksmtuned
## Write arbitrary files to the file-system (including binaries!)
@@ -42,10 +39,21 @@ write_files:
./manage-maas-nodes.sh -c
permissions: '0755'
owner: root:root
- path: /root/linux_kvm.sh
- path: /root/install_kvm.sh
content: |
#!/bin/bash
series=$(grep UBUNTU_CODENAME /etc/os-release | sed -e 's/UBUNTU_CODENAME=//g')
if [[ $series == "bionic" ]]
pkgs="qemu-kvm libvirt-bin qemu-efi"
else
pkgs="libvirt-daemon-system libvirt-clients"
fi
apt -y update
apt -y install $pkgs
mkdir -p /home/virsh/bin
ln -s /usr/bin/virsh /home/virsh/bin/virsh
sh -c echo "PATH=/home/virsh/bin" >> /home/virsh/.bashrc
@@ -58,16 +66,14 @@ write_files:
ForceCommand nc -q 0 -U /var/run/libvirt/libvirt-sock
EOF
systemctl restart sshd
usermod -a -G libvirt,libvirt-qemu virsh
permissions: '0755'
owner: root:root
# Runs any command that we need to run post install
runcmd:
- [ "/root/linux_kvm.sh" ]
- [ "rm", "/root/linux_kvm.sh" ]
- [ "usermod", "-a", "-G", "libvirt", "virsh" ]
- [ "usermod", "-a", "-G", "libvirt-qemu", "virsh" ]
- [ "efibootmgr", "-n", "0001"]
- [ "systemctl", "enable", "ksmtuned"]
- [ "systemctl", "restart", "ksmtuned"]
- [ "/root/install_kvm.sh" ]
- [ "rm", "/root/install_kvm.sh" ]
- [ "/root/initial_setup.sh" ]
- [ "rm", "/root/initial_setup.sh" ]