Arif Ali
c95bff6d92
* Make password and virsh user consistent on hp01 * Update the config to reflect the network config from hp01 * Add timezone and byobu config in cloud init
95 lines
2.1 KiB
YAML
95 lines
2.1 KiB
YAML
#cloud-config
|
|
|
|
ssh_import_id:
|
|
- lp:arif-ali
|
|
|
|
byobu_by_default: enable
|
|
|
|
timezone: "Europe/London"
|
|
|
|
# Allow ssh passwords
|
|
ssh_pwauth: True
|
|
|
|
## Update apt database and upgrade packages on first boot
|
|
package_update: true
|
|
package_upgrade: true
|
|
|
|
users:
|
|
- default
|
|
- name: virsh
|
|
lock_passwd: false
|
|
passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/
|
|
shell: "/bin/rbash"
|
|
|
|
## Install additional packages on first boot
|
|
packages:
|
|
- virtinst
|
|
- bc
|
|
- jq
|
|
- ksmtuned
|
|
|
|
snap:
|
|
commands:
|
|
- ['install', 'maas']
|
|
|
|
## 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/configs
|
|
ln -sf ${HOSTNAME}.config hypervisor.config
|
|
|
|
cd ../
|
|
chmod +x manage-maas-nodes.sh
|
|
./manage-maas-nodes.sh -c
|
|
permissions: '0755'
|
|
owner: root:root
|
|
- path: /root/install_kvm.sh
|
|
content: |
|
|
#!/bin/bash
|
|
|
|
series=$(lsb_release -c -s)
|
|
|
|
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
|
|
|
|
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
|
|
|
|
usermod -a -G libvirt,libvirt-qemu virsh
|
|
permissions: '0755'
|
|
owner: root:root
|
|
- path: /root/wipe_disk.sh
|
|
content: |
|
|
#!/bin/bash
|
|
|
|
dd if=/dev/zero of=/dev/sda bs=1M count=1000
|
|
permissions: '0755'
|
|
owner: root:root
|
|
|
|
# Runs any command that we need to run post install
|
|
runcmd:
|
|
- [ "/root/install_kvm.sh" ]
|
|
- [ "rm", "/root/install_kvm.sh" ]
|
|
- [ "/root/initial_setup.sh" ]
|
|
- [ "rm", "/root/initial_setup.sh" ]
|