Pcornel
Browse topics
Options
Recent
Favorites
Virtualization · Technical reference

Cloud-init · Automation

Direct answer

Cloud-init is the first-boot agent in most Linux cloud images: it reads user-data and meta-data from a datasource (NoCloud ISO, config drive, metadata service) to set hostname, users, SSH keys, network, packages and run commands.

When to use this

Use this when new Linux VMs must get hostname, users, SSH keys and network on first boot, or when cloud-init did not apply.

First 30 seconds

1. cloud-init customises VMs at first boot.

2. Use with cloud images and templates.

3. Check logs in guest.

4. Keep secrets out of user-data where possible.

5. Validate schema.

Operational verification

user-data → cloud-init → configured VM

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
virtualization
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
Scope / prerequisiteUse this when new Linux VMs must get hostname, users, SSH keys and network on first boot, or when cloud-init did not ap…
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.

2 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 Checks Verify boundary
  • cloud-init status --long → status: done.
  • Hostname, users and keys applied.
  • No errors in /var/log/cloud-init.log.
Step 2 Common mistakes Narrow the fault
  • Image captured without cloud-init clean, so it does not run again.
  • YAML errors (validate with cloud-init schema --config-file user-data).
  • No datasource attached (cloud-init drive missing).
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
  • cloud-init runs per instance ID; clones may not rerun.
  • Wrong datasource = nothing applied.
  • YAML errors silently skip modules.
Key checks
  • cloud-init status --long — guest result
  • qm cloudinit dump <vmid> user — Proxmox user-data
  • cloud-init schema --config-file user-data — validate YAML
ReferenceWhy it matters1 section · depth on demand

Datasources

PlatformDatasource
ProxmoxNoCloud (cloud-init drive)
vSphereVMware (guestinfo) or OVF
OpenStackConfigDrive/metadata service
Public cloudsProvider metadata service
ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

cloud-init configures a VM on first boot from metadata: hostname, users and SSH keys, network, packages, files and commands. Hypervisors provide the data through a config drive (NoCloud ISO in Proxmox, OVF/vApp properties or guestinfo in VMware, VHD with NoCloud in Hyper-V).

#cloud-config
hostname: web01
users:
  - name: ops
    groups: sudo
    shell: /bin/bash
    ssh_authorized_keys: ["ssh-ed25519 AAAA… ops@admin"]
package_update: true
packages: [qemu-guest-agent]
runcmd: [systemctl enable --now qemu-guest-agent]

Debug: cloud-init status --long, /var/log/cloud-init.log, cloud-init query --all.

Example user-data

#cloud-config
hostname: web01
users:
  - name: patrick
    ssh_authorized_keys: [ "ssh-ed25519 AAAA..." ]
    sudo: ALL=(ALL) NOPASSWD:ALL
package_update: true
packages: [ qemu-guest-agent ]

Documented example, not captured output. Check results in the guest with cloud-init status --long and /var/log/cloud-init.log.

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 current

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

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

Confirm action

Continue?