How to Create a Ubuntu Cloud VM Template on Proxmox VE

Create a Linux template VM on Proxmox VE.

Download the Ubuntu Cloud image to Proxmox VE

# curl -O https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img

Resize the cloud image to 20G

# qemu-img resize noble-server-cloudimg-amd64.img 20G

Add the cloud image as disk to the template VM

# qm disk import 101 noble-server-cloudimg-amd64.img local-lvm

Enable Snippets in the local storage and create a snippet file in the path /var/lib/vz/snippets/vendor.yaml

#cloud-config
runcmd:
- apt update
- apt install qemu-guest-agent -y
- rm -v /etc/ssh/sshd_config.d/*.conf
- echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/50-cloudinit-enable-root-login.conf
- reboot

The same configuration may be written as follows:

#cloud-config
write_files:
  - path: /etc/ssh/sshd_config.d/permit_root_login.conf
    permissions: '0644'
    content: |
      PermitRootLogin yes
runcmd:
  - systemctl restart sshd
  - apt update
  - apt install qemu-guest-agent -y
  - reboot 

Add the snippet file to the template VM

# qm set 101 --cicustom "vendor=local:snippets/vendor.yaml"

Configure CloudInit for the template VM from the Proxmox VE UI and click on Regenerate Image.

Add a Serial Port to the template VM.

Change the boot order of the template VM.

The VM template should be ready.

Post Tags: