Skip to content

Instantly share code, notes, and snippets.

@arevindh
Forked from chris2k20/Proxmox-Cloudinit.sh
Created October 14, 2023 17:32
Show Gist options
  • Save arevindh/ce10f4ced044747582cc887641046855 to your computer and use it in GitHub Desktop.
Save arevindh/ce10f4ced044747582cc887641046855 to your computer and use it in GitHub Desktop.
Proxmox Cloud-Init Template Creation Bash-Script (Ubuntu)
#!/bin/bash
# Creats a ubuntu Cloud-Init Ready VM Template in Proxmox
#
# https://gist.github.com/chris2k20/dba14515071bd5a14e48cf8b61f7d2e2
#
export IMAGENAME="focal-server-cloudimg-amd64.img"
export IMAGEURL="https://cloud-images.ubuntu.com/focal/current/"
export STORAGE="local-zfs-cache"
export VMNAME="ubuntu-2004-cloudinit-template"
export VMID=9000
export VMMEM=2048
export VMSETTINGS="--net0 virtio,bridge=vmbr0"
wget -O ${IMAGENAME} --continue ${IMAGEURL}/${IMAGENAME} &&
qm create ${VMID} --name ${VMNAME} --memory ${VMMEM} ${VMSETTINGS} &&
qm importdisk ${VMID} ${IMAGENAME} ${STORAGE} &&
qm set ${VMID} --scsihw virtio-scsi-pci --scsi0 ${STORAGE}:vm-${VMID}-disk-0 &&
qm set ${VMID} --ide2 ${STORAGE}:cloudinit &&
qm set ${VMID} --boot c --bootdisk scsi0 &&
qm set ${VMID} --serial0 socket --vga serial0 &&
qm template ${VMID} &&
echo "TEMPLATE ${VMNAME} successfully created!" &&
echo "Now create a clone of VM with ID ${VMID} in the Webinterface.."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment