proxmox

How to Set Up Cloud-Init Templates in Proxmox

A standard VM template still requires manually setting a hostname, network configuration, and SSH keys after cloning. Combining cloud-init with Proxmox templates removes even that remaining manual step, letting each cloned VM configure itself automatically on first boot based on parameters you set right in the Proxmox web interface.

What Is Cloud-Init?

Cloud-init is an industry-standard tool for automating a VM’s initial configuration on first boot — setting the hostname, network settings, user accounts, and SSH keys without any manual intervention inside the guest OS. It’s the same technology cloud providers like AWS and DigitalOcean use to let you launch a pre-configured instance instantly, and Proxmox has built-in support for using it with your own templates.

Why This Matters Beyond Basic Templates

The VM template approach covered in an earlier guide gets you a fast starting point, but you still typically log in and manually adjust hostname and network settings per clone. Cloud-init automates that final step entirely — you set the desired hostname, IP configuration, and SSH key directly in Proxmox’s VM options before first boot, and the VM configures itself accordingly the moment it starts.

Requirements

You’ll need a cloud-init-enabled cloud image as your template’s base, rather than a standard ISO installation. Most major distributions provide official cloud images specifically built with cloud-init pre-installed — Ubuntu, Debian, and Rocky Linux all publish these as .qcow2 or .img files intended exactly for this use case.

Downloading a Cloud Image

On your Proxmox host, download an official cloud image (Ubuntu’s is used here as an example):

wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

Creating a New VM from the Cloud Image

Create a new VM shell without installing an OS from an ISO:

qm create 9000 --name ubuntu-cloudinit-template --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0

Importing the Cloud Image as the VM’s Disk

qm importdisk 9000 jammy-server-cloudimg-amd64.img local-lvm

Attach the imported disk through the Proxmox web interface, or via command line:

qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-0

Adding a Cloud-Init Drive

This special drive is what actually carries the cloud-init configuration data to the VM at boot:

qm set 9000 --ide2 local-lvm:cloudinit

Configuring Boot Order and Serial Console

Cloud images typically expect a serial console rather than the standard display, and the disk needs to be set as the boot device:

qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0

Converting to a Template

Once configured, convert this VM into a template exactly as covered in the standard VM template guide — right-click the VM in the Proxmox web interface and select Convert to Template.

Cloning and Configuring a New VM

Clone the template as usual, then before starting the new VM, configure its cloud-init settings directly in the Proxmox web UI under the cloned VM’s Cloud-Init tab:

  • User – set a default login username
  • SSH Public Key – paste your public key for immediate passwordless access
  • IP Config – set a static IP or leave as DHCP
  • Hostname – (configured via the VM’s name, or explicitly through additional cloud-init options)

First Boot Behavior

When the cloned VM starts, cloud-init reads the configuration you set and applies it automatically — setting the hostname, configuring networking, and installing your SSH key — all before you ever need to log in manually, turning what used to be several minutes of manual post-clone configuration into a fully automated process.

Combining with Ansible for Full Automation

For an even more hands-off homelab workflow, pair cloud-init (handling initial VM-level configuration) with Ansible (covered in an earlier guide, handling application-level configuration afterward) — together automating a VM from completely blank template to fully configured, running service with no manual steps at all.

Final Thoughts

Setting up cloud-init with Proxmox templates eliminates the last manual step remaining after basic VM cloning, automatically configuring hostname, networking, and SSH access the moment a new VM boots. For homelab users who create new VMs regularly — testing environments, new services, or disposable sandboxes — this level of automation meaningfully speeds up an already efficient template-based workflow.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *