Skip to content

Instantly share code, notes, and snippets.

@mikenabhan
Last active July 6, 2022 01:05
Show Gist options
  • Save mikenabhan/fd0080a0cf059cf0b91ccc0cf9042452 to your computer and use it in GitHub Desktop.
Save mikenabhan/fd0080a0cf059cf0b91ccc0cf9042452 to your computer and use it in GitHub Desktop.
Proxmox Ubuntu 22.04 Cloud Init Template
#!/usr/bin/env bash
set -xeu
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
virt-customize -a jammy-server-cloudimg-amd64.img --install qemu-guest-agent
virt-sysprep -a jammy-server-cloudimg-amd64.img --operations machine-id
STORAGE_POOL="local-lvm"
VM_ID="12000"
VM_NAME="ubuntu-22.04-cloudimg"
qm create $VM_ID --memory 2048 --net0 virtio,bridge=vmbr0
qm importdisk $VM_ID jammy-server-cloudimg-amd64.img $STORAGE_POOL
qm set $VM_ID --scsihw virtio-scsi-pci --scsi0 $STORAGE_POOL:vm-$VM_ID-disk-0
qm set $VM_ID --agent enabled=1,fstrim_cloned_disks=1
qm set $VM_ID --name $VM_NAME
qm set $VM_ID --tablet 0
qm set $VM_ID --ide2 $STORAGE_POOL:cloudinit
qm set $VM_ID --boot c --bootdisk scsi0
qm set $VM_ID --serial0 socket --vga serial0
qm template $VM_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment