Skip to content

Latest commit

 

History

History
38 lines (22 loc) · 1.76 KB

cloud-init.md

File metadata and controls

38 lines (22 loc) · 1.76 KB

cloud init

cloud-init runs as root, to view the logs:

sudo less /var/log/cloud-init-output.log

view user data for current instance:

sudo cat /var/lib/cloud/instance/user-data.txt

(previous instance instantiations are available in /var/lib/cloud/instances/)

Package modules

The Package Update Upgrade Install module can be specified in cloud config and will run before any user data scripts.

User data

User data scripts (text/x-shellscript) are executed during first boot at "rc.local-like" level ie: very late in the boot sequence (ref).

User data scripts are stored in /var/lib/cloud/instance/scripts/. A single script is stored with the filename part-001. Scripts have rwx for root only.

MIME multi-part

Each part in a mime multi-part file will be stored on disk in /var/lib/cloud/instance/scripts/ using the filename provided in the part, or as files named part-XXX if no filename is specified. text/x-shellscript parts are executed in alphanumeric order according to their filename as stored on disk.

If one script has a non-zero exit code, cloud init will still run the other scripts.

See cloud-init-example for an ordering example.

Write arbitrary files

Write arbitrary files via the write_files key in the cloud-config file. (example).