From d3453fcab9686b9550614081f3039bc272c7bc0b Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 25 Dec 2020 17:03:36 +0000 Subject: [PATCH] Add user_dats file and update password --- .gitignore | 1 + asrock01.config | 2 +- manage-hypervisor-nodes.sh | 8 ++++++- user-data.yaml | 46 ++++++++++++++++++++++++-------------- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 8969b65..2427360 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ maas.config maas.debconf +*.xml diff --git a/asrock01.config b/asrock01.config index 6d06807..536c8fe 100644 --- a/asrock01.config +++ b/asrock01.config @@ -5,7 +5,7 @@ hypervisor_mac="a8:a1:59:44:70:ac" external_vlan=1 qemu_connection="qemu+ssh://virsh@${hypervisor_ip}/system" -qemu_password="seBGtkWFKZuFUFgig8NYU5uh" +qemu_password="SgUoBByKjG9Lj78SwfWAHXD8DvgE67Cu" storage_path="/var/lib/libvirt/maas-images" diff --git a/manage-hypervisor-nodes.sh b/manage-hypervisor-nodes.sh index 2d97ffa..c378119 100755 --- a/manage-hypervisor-nodes.sh +++ b/manage-hypervisor-nodes.sh @@ -162,7 +162,13 @@ destroy_node() { deploy_node() { system_id=$(maas_system_id ${hypervisor_name}) - maas ${maas_profile} machine deploy ${system_id} install_kvm=true user_data="$(base64 user-data.yaml)" + #maas ${maas_profile} machine deploy ${system_id} install_kvm=true user_data="$(base64 user-data.yaml)" + + maas ${maas_profile} machine deploy ${system_id} user_data="$(base64 user-data.yaml)" + + # TODO: keep trying, until it gives a valid output + #until $(maas ${maas_profile} machine deploy ${system_id} install_kvm=true) ; do + # machine ${maas_profile} machine release ${system_id} } show_help() { diff --git a/user-data.yaml b/user-data.yaml index 3208d76..d1c2543 100644 --- a/user-data.yaml +++ b/user-data.yaml @@ -3,29 +3,41 @@ ssh_import_id: - lp:arif-ali -groups: - - virsh - -user: - - name: virsh - primary_group: virsh - groups: libvirt, libvirt-qemu - #password: SZRMBxvfBnhNRUFdo4kZh3RYwVZYCy5Q - password: $6$rounds=4096$wkZS4scqVpL6NHio$nwiGisbbwy0/YDYT391xc0lNs.6JX4tDcJ26Z3XMhloT1bI2pS6aMB0LXQ3noOzRD2I.OEzy/7YVEjwVAGzlM0 - ## Update apt database and upgrade packages on first boot package_update: true package_upgrade: true +users: + - default + - name: virsh + primary_group: virsh + groups: [ libvirt, libvirt-qemu ] + passwd: $6$rounds=4096$lSbs3gFH3KhLmbWi$EYqoyw2QreaFBonLX8VQgcCGdWktsggp2j/D3qAnQT6azw92hZR8Vvu.wVlDzBaCPPzh8HO.QPprzVruEoqLP0 + ## Install additional packages on first boot packages: -- virtinst -- bc -- jq + - virtinst + - bc + - jq + - qemu-kvm + - libvirt-bin + - qemu-efi + +## 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 maas-autobuilder/hypervisor.config + + chmod +x manage-maas-nodes.sh + ./manage-maas-nodes.sh + permissions: '0755' + owner: root:root # Runs any command that we need to run post install runcmd: -- [ "git", "clone", "https://github.com/arif-ali/maas-autobuilder.git" ] -- [ "ln", "-sf", "maas-autobuilder/${HOSTNAME}.config", "maas-autobuilder/hypervisor.config" ] -- [ "cd", "maas-autobuilder", "&&", "./manage-maas-nodes.sh" ] -- [ "sudo", "efibootmgr", "-n", "0001" ] +- [ "/root/initial_setup.sh" ]