2020-12-25 15:48:50 +00:00
|
|
|
#cloud-config
|
|
|
|
|
|
|
|
ssh_import_id:
|
|
|
|
- lp:arif-ali
|
|
|
|
|
2020-12-25 20:11:38 +00:00
|
|
|
# Allow ssh passwords
|
|
|
|
ssh_pwauth: True
|
|
|
|
|
2020-12-25 15:48:50 +00:00
|
|
|
## Update apt database and upgrade packages on first boot
|
|
|
|
package_update: true
|
|
|
|
package_upgrade: true
|
|
|
|
|
|
|
|
users:
|
|
|
|
- default
|
|
|
|
- name: virsh
|
2020-12-25 18:16:11 +00:00
|
|
|
lock_passwd: false
|
2020-12-25 20:11:38 +00:00
|
|
|
passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/
|
|
|
|
shell: "/bin/bash"
|
2020-12-25 15:48:50 +00:00
|
|
|
|
|
|
|
## Install additional packages on first boot
|
|
|
|
packages:
|
|
|
|
- virtinst
|
|
|
|
- bc
|
|
|
|
- jq
|
|
|
|
- qemu-kvm
|
|
|
|
- libvirt-bin
|
|
|
|
- qemu-efi
|
2020-12-25 19:48:41 +00:00
|
|
|
- ksmtuned
|
2020-12-25 15:48:50 +00:00
|
|
|
|
|
|
|
## Write arbitrary files to the file-system (including binaries!)
|
|
|
|
write_files:
|
|
|
|
- path: /root/initial_setup.sh
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
git clone https://github.com/arif-ali/maas-autobuilder.git /root/maas-autobuilder
|
|
|
|
cd /root/maas-autobuilder
|
|
|
|
ln -sf ${HOSTNAME}.config hypervisor.config
|
|
|
|
|
|
|
|
chmod +x manage-maas-nodes.sh
|
|
|
|
./manage-maas-nodes.sh -c
|
|
|
|
permissions: '0755'
|
|
|
|
owner: root:root
|
2020-12-26 09:50:10 +00:00
|
|
|
- path: /root/update_sshd.sh
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cat >> /etc/ssh/sshd_config << EOF
|
|
|
|
Match user virsh
|
|
|
|
X11Forwarding no
|
|
|
|
AllowTcpForwarding no
|
|
|
|
PermitTTY no
|
|
|
|
ForceCommand nc -q 0 -U /var/run/libvirt/libvirt-sock
|
|
|
|
EOF
|
|
|
|
systemctl restart sshd
|
|
|
|
permissions: '0755'
|
|
|
|
owner: root:root
|
2020-12-25 15:48:50 +00:00
|
|
|
|
|
|
|
# Runs any command that we need to run post install
|
|
|
|
runcmd:
|
2020-12-25 20:11:38 +00:00
|
|
|
- [ "mkdir", "-p", "/home/virsh/bin" ]
|
|
|
|
- [ "ln", "-s", "/usr/bin/virsh", "/home/virsh/bin/virsh" ]
|
|
|
|
- [ "sh", "-c", 'echo "PATH=/home/virsh/bin" >> /home/virsh/.bashrc' ]
|
2020-12-26 09:50:10 +00:00
|
|
|
- [ "/root/update_sshd.sh" ]
|
|
|
|
- [ "rm", "/root/update_sshd.sh" ]
|
2020-12-25 19:48:41 +00:00
|
|
|
- [ "usermod", "-a", "-G", "libvirt", "virsh" ]
|
|
|
|
- [ "usermod", "-a", "-G", "libvirt-qemu", "virsh" ]
|
2020-12-25 20:11:38 +00:00
|
|
|
- [ "efibootmgr", "-n", "0001"]
|
2020-12-25 19:48:41 +00:00
|
|
|
- [ "systemctl", "enable", "ksmtuned"]
|
|
|
|
- [ "systemctl", "restart", "ksmtuned"]
|
2020-12-25 18:43:13 +00:00
|
|
|
- [ "/root/initial_setup.sh" ]
|