In this blog post I am going to look at creating a virtual machine (VM) template that has cloudinit so that some settings are automatically configured at launch of any VMs built from the template.
The first step towards a cloudinit template is finding a cloudinit image.
Ubuntu Cloudinit Images
Ubuntu maintains a page for their official cloud images. It is available at: https://cloud-images.ubuntu.com/?C=M;O=D . The directory contains many different versions of Ubuntu including both the regular release and the Long Term Support (LTS) release. Regular gets new features faster, LTS is supported for longer.
Inside the directory for the OS (e.g. noble for Noble Numbat) is then directories for specific versions, I would recommend using the /current/ directory. The file for the Cloudinit is ends with the file extension .img.
Note: There are amd64 and arm64 versions of the img file, make sure to choose the correct one for your processor architecture.
Copy the URL of the img file and head back to Proxmox.
ProxMox Shell
Within the Proxmox shell:
Download the image
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
Create a new VM.
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
This creates a VM with ID 9000. Make sure this does not conflict with any other VM IDs.
Import the image as a disk. I have saved it to the pi storage I recently created.
qm disk import 9000 noble-server-cloudimg-amd64.img pi
Make a note of the successful disk import message as it contains the path to the disk.

The disk will then need connecting to the VM.
qm set 9000 --scsihw virtio-scsi-pci --scsi0 pi:9000/vm-9000-disk-1.raw
Then add a Cloudinit drive.
qm set 9000 --ide2 pi:cloudinit
Make the Cloudinit drive bootable.
qm set 9000 --boot c --bootdisk scsi0
Add a serial console.
qm set 9000 --serial0 socket --vga serial0
Make the VM into a template.
qm template 9000
The template can then be cloned into a VM (i.e. you end up with a VM based on the template, and the template which can be used again in future).
qm clone 9000 200 --name clonetest --full
9000 is the ID of the template. 200 is the ID for the new machine. clonetest is the name of the new machine. Full means a full clone (it can live without the template), the other option is link (it is linked to the template and requires the template to remain in place).