cloud-init builds a single configuration that is then
referenced throughout the life of
cloud-init. The configuration is built
from multiple sources such that if a key is defined in multiple sources, the
higher priority source overwrites the lower priority source.
From lowest priority to highest, configuration sources are:
Hardcoded config: Config that lives within the source of
cloud-initand cannot be changed.
Configuration directory: Anything defined in
Runtime config: Anything defined in
Kernel command line: On the kernel command line, anything found between
end_ccwill be interpreted as cloud-config user data.
These four sources make up the base configuration.
Vendor and user data#
These get fetched from the datasource and are defined at instance launch.
While much of what is defined in the base configuration can be overridden by vendor data and user data, base configuration sources do not conform to #cloud-config.
Network configuration happens independently from other
configuration. See network configuration documentation
for more information.
Pass user data to the cloud provider.
Every platform supporting
cloud-init will provide a method of supplying
user data. If you’re unsure how to do this, reference the documentation
provided by the cloud platform you’re on. Additionally, there may be
cloud-init documentation in the datasource
Once an instance has been initialised, the user data may not be edited. It is sourced directly from the cloud, so even if you find a local file that contains user data, it will likely be overwritten in the next boot.
Modify the base config. This often involves submitting a PR to modify
the base cloud.cfg template, which is used to customise
/etc/cloud/cloud.cfg per distro. Additionally, a file can be added to
/etc/cloud/cloud.cfg.d to override a piece of the base configuration.
Pass vendor data. This is the preferred method for clouds to provide their own customisation. In some cases, it may make sense to modify the base config in the same manner as distro providers on cloud-supported images.