cloud-init
Initialize cloud instances on first boot
TLDR
Display the status of the most recent cloud-init run
Wait for cloud-init to finish running and then report status
List available top-level metadata keys to query
Query cached instance metadata for data
Clean logs and artifacts to allow cloud-init to rerun
SYNOPSIS
cloud-init [options...] subcommand [args...]
e.g., cloud-init init [--local] [--network]
PARAMETERS
--help, -h
Show help message and exit
--version
Show cloud-init version
--verbose, -v
Increase verbosity (repeat for more)
--debug, -d
Enable debug logging
--quiet, -q
Reduce logging verbosity
--file FILE, -f FILE
Read configuration from FILE
--frequency FREQ
De-duplication frequency (e.g., 'once', 'always')
--force
Force execution regardless of cache
--log-dir LOG_DIR
Use custom log directory
--log-file LOG_FILE
Log to specific file
--no-cache
Disable cache usage
--local
Run local stage only (early boot)
DESCRIPTION
cloud-init is the industry-standard tool for initializing cloud instances across distributions like Ubuntu, CentOS, Debian, and RHEL. It runs during the first boot to apply user-provided configuration data fetched from metadata services (e.g., AWS EC2, Azure, OpenStack, GCP).
It processes YAML-formatted cloud-config data through three main stages: init (early boot, networking), config (per-boot, hostname, users, packages), and final (late boot, services). Modules handle tasks like resizing filesystems, managing SSH keys, installing snaps/packages, writing files, and running scripts.
cloud-init supports datasource plugins for cloud detection and is idempotent, ensuring safe re-runs. Logs are in /var/log/cloud-init*. It's essential for IaC tools like Terraform and Packer, enabling reproducible environments without manual post-boot intervention.
CAVEATS
Requires cloud metadata services; may fail on non-cloud VMs. Not for repeated runs without --force. Logs can grow large; use cloud-init clean to reset.
MAIN SUBCOMMANDS
init: Run init stage.
modules: List/analyze modules.
status: Check status.
clean: Reset state.
collect-logs: Gather logs.
CONFIG SOURCES
Data from NoCloud, ConfigDrive, EC2, OpenStack, etc. See /etc/cloud/cloud.cfg.d/.
HISTORY
Developed in 2008 by Scott Moser at Canonical for Ubuntu cloud images. Evolved for MAAS, OpenStack; upstreamed in 2014. Now maintained by Canonical, supports 20+ distros, version 24.2+ as of 2024.
SEE ALSO
cloud-init status(7), ds-identify(8), cloud-config(5), growpart(8), curtin(7)


