From cd550ec3786802da7786812395ae6b7e7a67f932 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 25 Dec 2020 20:11:38 +0000 Subject: [PATCH] Add stuff from maas function when install_kvm=true https://git.launchpad.net/maas/tree/src/metadataserver/vendor_data.py?h=2.8#n168 using install_kvm=true vi the deploy and having user_data didn't work so using this method instead --- user-data.yaml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/user-data.yaml b/user-data.yaml index f7d43f5..83456af 100644 --- a/user-data.yaml +++ b/user-data.yaml @@ -3,6 +3,9 @@ ssh_import_id: - lp:arif-ali +# Allow ssh passwords +ssh_pwauth: True + ## Update apt database and upgrade packages on first boot package_update: true package_upgrade: true @@ -10,9 +13,9 @@ package_upgrade: true users: - default - name: virsh - primary_group: virsh - passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/ lock_passwd: false + passwd: $6$SVOxUrhz9mNyscUJ$hKF0RMY1nkGC3BpiozpaznE3AWerd8Ac8AlV9YEpLx50bLw5zweFCuTEEdS04McJNlaIqA.E4HiPuaIYGMzlH/ + shell: "/bin/bash" ## Install additional packages on first boot packages: @@ -30,10 +33,6 @@ write_files: content: | #!/bin/bash - # Enable SSH, so that virsh can login - sed -i "s/^\(PasswordAuthentication\).*/\1 yes/g" /etc/ssh/sshd_config - systemctl restart sshd - git clone https://github.com/arif-ali/maas-autobuilder.git /root/maas-autobuilder cd /root/maas-autobuilder ln -sf ${HOSTNAME}.config hypervisor.config @@ -45,9 +44,23 @@ write_files: # Runs any command that we need to run post install runcmd: - - [ "efibootmgr", "-n", "0001"] + - [ "mkdir", "-p", "/home/virsh/bin" ] + - [ "ln", "-s", "/usr/bin/virsh", "/home/virsh/bin/virsh" ] + - [ "sh", "-c", 'echo "PATH=/home/virsh/bin" >> /home/virsh/.bashrc' ] + - [ + "sh", + "-c", + 'printf "Match user virsh\\n' + " X11Forwarding no\\n" + " AllowTcpForwarding no\\n" + " PermitTTY no\\n" + ' ForceCommand nc -q 0 -U /var/run/libvirt/libvirt-sock\\n"' + " >> /etc/ssh/sshd_config", + ] - [ "usermod", "-a", "-G", "libvirt", "virsh" ] - [ "usermod", "-a", "-G", "libvirt-qemu", "virsh" ] + - [ "systemctl", "restart", "sshd"] + - [ "efibootmgr", "-n", "0001"] - [ "systemctl", "enable", "ksmtuned"] - [ "systemctl", "restart", "ksmtuned"] - [ "/root/initial_setup.sh" ]