Cloud-init

Cloud-init is a package that contains utilities for early initialization of cloud instances. It is needed in Arch Linux images that are built with the intention of being launched in cloud like OpenStack, AWS etc.

Disable login as root

Do not perform this step unless you are sure the configuration in previous section works. Otherwise you might be completely locked out of your instance.

Configuring data sources

Data Sources define how the instance metadata is pulled during boot. This depends on what cloud (OpenStack, AWS, OpenNebula etc.) you are running your instance on. Under the hood this translates to a corresponding module which implement a few methods defined in a common interface. Edit your /etc/cloud/cloud.cfg to have the below contents:

The above configuration tells OpenStack datasource to use the url http://169.254.169.254:80 to download metadata and to run after network initialization, both of which are the default behaviour and may be omitted.

Other sections in cloud.cfg

cloud.cfg defines several other sections which includes but not limited to cloud_init_modules, cloud_config_modules and cloud_final_modules that define the modules that would be run at various stages during instance initialization. These modules are loaded dynamically from the path /usr/lib/python2.7/site-packages/cloudinit/config/ and run at boot time. The user may define their own modules and configure them to be called during every boot like say to:

perform disk resize

perform package update

etc.

The various modules declare to cloud-init which distros they have been verified for. Even if you specify that you want to run them, they will refuse to run unless the distro specified in cloud.cfg is one of the verified distros for the given module. If you want to run a module on Arch anyway that does not specify arch, add the module to the unverified_modules: section in cloud.cfg, e.g.:

unverified_modules: ['ssh-import-id']

Systemd integration

Package cloud-init provides 4 systemd services, and a systemd target, whose dependencies are constructed in a way that they are activated in the sequence listed:

cloud-init-local.service. Only requires the filesystems to be up. Executes cloud-init init --local

cloud-init.service. Requires the network to be up. Executes cloud-init init

cloud-config.target. Corresponds to the cloud-config upstart event "to inform third parties that cloud-config is available"

cloud-config.service. Executes cloud-init modules --mode=config

cloud-final.service. Executes cloud-init modules --mode=final

The Uplink Labs EC2 images have all of them enabled, although that appears to be overkill due to the dependencies.