Post

Creating Cloud-Init Enabled Ubuntu VM Templates in Proxmox

Creating Cloud-Init Enabled Ubuntu VM Templates in Proxmox

Introduction

This guide walks through creating a cloud-init enabled Ubuntu template in Proxmox for rapid VM provisioning. Cloud-init automates initial server configuration including user accounts, network settings, and package installation.


Preparing the Cloud-Init Image

1. Access Proxmox Host

First, connect to your Proxmox server via SSH:

1
ssh proxmox-server-username@proxmox-server-ip

2. Download Ubuntu Cloud Image

1
2
export VM_ID="500"
wget -O ubuntu.img https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img

3. Image Customization

Install QEMU Guest Agent:

1
2
3
virt-customize -a ubuntu.img \
--install qemu-guest-agent \
--run-command 'systemctl enable qemu-guest-agent.service'

Creating Proxmox VM Template

1. Configure Base VM

1
2
3
4
5
6
qm create ${VM_ID} \
--name ubuntu-24.04-cloudimg-template \
--agent 1,fstrim_cloned_disks=1 \
--core 4 \
--memory 8192 \
--net0 virtio,bridge=vmbr0

2. Import and Attach Disk

1
2
3
4
qm importdisk ${VM_ID} ubuntu.img local-lvm
qm set ${VM_ID} \
--scsihw virtio-scsi-pci \
--scsi0 local-lvm:vm-${VM_ID}-disk-0

3. Configure Cloud-Init

1
2
3
4
qm set ${VM_ID} \
--ide2 local-lvm:cloudinit \
--boot c --bootdisk scsi0 \
--serial0 socket --vga serial0

4. Finalize Template

1
qm template ${VM_ID}

Deploying VM from Template

1. Clone and Configure

  1. Right-click template → Clone
  2. Select Full Clone mode
  3. In Cloud-Init tab:
    • Username: Set username(e.g., ubuntu)
    • Password: Set secure password
    • SSH Keys: Paste your public key
    • IP Configuration:
      • DHCP (recommended)
      • Static IP:
        • Address/CIDR: 192.168.1.100/24
        • Gateway: 192.168.1.1
        • DNS: 8.8.8.8 8.8.4.4
  4. Click Regenerate Image

2. Start and Connect

  1. Launch VM → Check IP in Summary tab
  2. SSH access examples:
1
ssh username@vm-dhcp-ip-address

This post is licensed under CC BY 4.0 by the author.