You will need to have a prepared Cloud Image with Cloud-Init. Check out this guide to see how to prepare the Cloud Image.
Step 1: Create a Virtual Machine
You will need to create the VM if it doesn’t exist already. Our storage is nvm_storage in this example. You will need to use the storage path/naming convention allocated in Proxmox. We will use the AlmaLinux 8 image that we prepared in the Cloud Image preparation guide.
Log in to SSH on your server, then create a new VM with the following.
qm create 500 --memory 256 --net0 virtio,bridge=vmbr0
Import the Cloud Image that you have prepared to the VM storage.
qm importdisk 500 AlmaLinux-8-GenericCloud-8.6-20220718.x86_64.qcow2 nvm_storage
Attach the new disk to the VM as an SCSI Drive
qm set 500 --scsihw virtio-scsi-pci --scsi 0 nvm_storage:vm-500-disk-1
Add a CDROM drive which will be used to pass the Cloud-Init data to the VM.
qm set 500 -ide2 nvm_storage:cloudinit
To boot from the Cloud-Init image, you will need to set the boot parameter to scsi0 and restrict the BIOS to boot from disk only.
qm set 500 --boot c --bootdisk scsi0
You will need to configure a serial console and use it as a display, this is because many Cloud-Init images rely on this as it is a requirement for OpenStack images.
qm set 500 --serial0 socket --vga serial0
You can check in the Proxmox GUI to see the configuration of the VM. Once all of the above has been done, you are ready to convert the VM to a Template.
qm template 500
And that’s it, you’re done! Repeat for each Cloud-Init image you wish to set up.