Pcornel
Browse topics
Options
Recent
Favorites
Virtualization · Technical reference

Cloud-init · VM Templates

Direct answer

Cloud-init in templates customizes each new clone from the same image: pass user-data with hostname, users, SSH keys, network and packages through a NoCloud drive or the hypervisor's cloud-init settings.

When to use this

Use this when templates use cloud-init to customize each clone.

First 30 seconds

1. cloud-init configures a VM on first boot: hostname, users, SSH keys, network, packages.

2. Datasource: NoCloud ISO, ConfigDrive, cloud metadata.

3. Logs: /var/log/cloud-init.log.

4. Runs once per instance-id.

5. Validate YAML: cloud-init schema --config-file.

Operational verification

datasource → cloud-init stages → configured guest

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
virtualization-image
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformvirtualization-image
Scope / prerequisiteUse this when templates use cloud-init to customize each clone.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Common mistakes Narrow the fault
  • Template captured with cloud-init state left (it will not run again).
  • Network config in user-data conflicting with the platform's network config.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Validate user-data before using it.
Key checks
  • cloud-init status --long — cloud-init result in guest
  • qm cloudinit dump <vmid> user — generated user-data (Proxmox)
  • cloud-init query -a | head — datasource info
ReferenceWhy it matters1 section · depth on demand

How it works

Cloud-init runs at first boot, reads metadata/user-data from a datasource (config drive, NoCloud ISO, cloud metadata service) and configures hostname, users, SSH keys, network and packages.

ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

NoCloud seed for KVM/libvirt

The cloud-init NoCloud documentation describes a seed with meta-data (must contain instance-id) and user-data (required, may be empty), plus optional vendor-data and network-config, typically delivered on a volume labelled CIDATA (vfat or iso9660).

$ cat meta-data
instance-id: web01-20261127
local-hostname: web01
$ cat user-data
#cloud-config
users:
  - name: admin
    groups: sudo
    shell: /bin/bash
    ssh_authorized_keys:
      - ssh-ed25519 AAAA... admin@laptop
package_update: true
packages: [qemu-guest-agent]
runcmd:
  - systemctl enable --now qemu-guest-agent
$ cloud-localds seed.iso user-data meta-data          # or: genisoimage -volid CIDATA -joliet -rock ...

Attach seed.iso as a CD-ROM. If you change user-data later, change the instance-id too — the documentation notes that cloud-init uses it to decide whether this is a first boot.

Proxmox VE built-in cloud-init

qm set 9000 --ide2 local-lvm:cloudinit
qm set 123 --ciuser admin --sshkeys ~/.ssh/id_ed25519.pub --ipconfig0 ip=10.0.20.51/24,gw=10.0.20.1 --nameserver 10.0.0.53
qm cloudinit dump 123 user           # show generated user-data
qm cloudinit update 123              # regenerate the drive after changes

Troubleshooting inside the guest

CheckCommand
Overall statuscloud-init status --long
What happened/var/log/cloud-init.log, /var/log/cloud-init-output.log
Which datasource was foundcloud-init query ds / cloud-id
Re-run for testing (lab only)cloud-init clean --logs && reboot

Common faults: YAML indentation errors (validate with cloud-init schema --config-file user-data), the seed attached without the CIDATA label, or a template image where cloud-init already ran and was not cleaned.

*The NoCloud seed configuration and Proxmox cloud-init commands above are illustrative examples, not captured from a lab or production host.*

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docvirtualization-image current

Authoritative/upstream documentation reviewed for bounded claims in VM Templates → Cloud-init. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://libvirt.org/docs.html · confidence 94%
Confirmation

Confirm action

Continue?