From c6ac06434aded112d04d2946cdfe8ae69a325fb3 Mon Sep 17 00:00:00 2001 From: Julien Escario Date: Fri, 18 Jun 2021 14:33:25 +0200 Subject: [PATCH] Re-enable image download, delete temporary files and (basic) test args --- cloud-init/create_ubuntu20_template.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cloud-init/create_ubuntu20_template.sh b/cloud-init/create_ubuntu20_template.sh index 143df47..2fc3f29 100644 --- a/cloud-init/create_ubuntu20_template.sh +++ b/cloud-init/create_ubuntu20_template.sh @@ -15,17 +15,26 @@ fi echo "Storage $_storage is valid and VM does not exists, let's get the latest Ubuntu-minimal image from repo" -# Récupération de l'image Ubuntu -#curl --progress-bar -o ubuntu-20.04-minimal-cloudimg-amd64.img https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img +# Fetching the last Ubuntu Minimal 20.04 cloud-image +curl --progress-bar -o ubuntu-20.04-minimal-cloudimg-amd64.img https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img # Silently download public SSH key curl -s -o support@altinea.fr.pub https://gitlab.altinea.fr/altinea/install-scripts/raw/branch/master/ssh/support@altinea.fr.pub +# Create VM, import cloud-image and configure storage /usr/sbin/qm create 9999 --memory 1024 --net0 virtio,bridge=vmbr0 /usr/sbin/qm importdisk 9999 ubuntu-20.04-minimal-cloudimg-amd64.img $_storage /usr/sbin/qm set 9999 --scsihw virtio-scsi-pci --scsi0 $_storage:vm-9999-disk-0,discard=on /usr/sbin/qm set 9999 --ide2 $_storage:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0 + +# Convert VM to template /usr/sbin/qm template 9999 + +# Adjust VM settings (based on best practices) /usr/sbin/qm set 9999 --args "-cpu 'kvm64,+ssse3,+sse4.1,+sse4.2,+x2apic'" --ciuser root --ipconfig0 ip=dhcp,ip6=dhcp --sshkeys support@altinea.fr.pub --name "Ubuntu20.04" --agent enabled=1 +# Delete temporary files +rm ubuntu-20.04-minimal-cloudimg-amd64.img +rm support@altinea.fr.pub + echo "All done, you can now clone VM9999 (Ubuntu20.04) from PVE interface"