What is the order of the directives in the cloud-config section of a cloud-init user-data object. This is important to avoid race type conditions.
I know bootcmd runs early and before runcmd, but is there a good list of the order of all the methods?
User data and cloud-init directives The cloud-init package configures specific aspects of a new Amazon Linux instance when it is launched; most notably, it configures the . ssh/authorized_keys file for the ec2-user so you can log in with your own private key.
Cloud-init config is provided in two places: /etc/cloud/cloud. cfg. /etc/cloud/cloud.
You can check the /var/lib/cloud/data/status. json for cloud-init status. Or if the host is using upstart, add one init process in /etc/init/newprocess.
Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server.
From https://git.launchpad.net/cloud-init/tree/config/cloud.cfg (thanks to garbelini)
(As of Sep 2017 the above link is incorrect and is now https://git.launchpad.net/cloud-init/tree/config/cloud.cfg.tmpl, see note below)
# The modules that run in the 'init' stage cloud_init_modules: - migrator - ubuntu-init-switch - seed_random - bootcmd - write-files - growpart - resizefs - set_hostname - update_hostname - update_etc_hosts - ca-certs - rsyslog - users-groups - ssh # The modules that run in the 'config' stage cloud_config_modules: # Emit the cloud config ready event # this can be used by upstart jobs for 'start on cloud-config'. - emit_upstart - disk_setup - mounts - ssh-import-id - locale - set-passwords - snappy - grub-dpkg - apt-pipelining - apt-configure - package-update-upgrade-install - fan - landscape - timezone - lxd - puppet - chef - salt-minion - mcollective - disable-ec2-metadata - runcmd - byobu # The modules that run in the 'final' stage cloud_final_modules: - rightscale_userdata - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - ssh-authkey-fingerprints - keys-to-console - phone-home - final-message - power-state-change
Additionally:
There is configuration merging "The order is the following: - cli config files override environment config files which override instance configs which override datasource configs which override base configuration which overrides default configuration." (see Changelog)
Within the individual generated script directories the scripts are run in the order given by the python "sorted()" builtin
NOTE: although this was correct at the time of answering, looking at the respository (as of Sept 2017) mentioned above there is now a cloud.cfg.tmpl template file which has slightly different settings for different distros
# The modules that run in the 'init' stage cloud_init_modules: - migrator - seed_random - bootcmd - write-files - growpart - resizefs {% if variant not in ["freebsd"] %} - disk_setup - mounts {% endif %} - set_hostname - update_hostname {% if variant not in ["freebsd"] %} - update_etc_hosts - ca-certs - rsyslog {% endif %} - users-groups - ssh # The modules that run in the 'config' stage cloud_config_modules: {% if variant in ["ubuntu", "unknown", "debian"] %} # Emit the cloud config ready event # this can be used by upstart jobs for 'start on cloud-config'. - emit_upstart - snap_config {% endif %} - ssh-import-id - locale - set-passwords {% if variant in ["rhel", "fedora"] %} - spacewalk - yum-add-repo {% endif %} {% if variant in ["ubuntu", "unknown", "debian"] %} - grub-dpkg - apt-pipelining - apt-configure {% endif %} {% if variant not in ["freebsd"] %} - ntp {% endif %} - timezone - disable-ec2-metadata - runcmd {% if variant in ["ubuntu", "unknown", "debian"] %} - byobu {% endif %} # The modules that run in the 'final' stage cloud_final_modules: {% if variant in ["ubuntu", "unknown", "debian"] %} - snappy {% endif %} - package-update-upgrade-install {% if variant in ["ubuntu", "unknown", "debian"] %} - fan - landscape - lxd {% endif %} {% if variant not in ["freebsd"] %} - puppet - chef - salt-minion - mcollective {% endif %} - rightscale_userdata - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - ssh-authkey-fingerprints - keys-to-console - phone-home - final-message - power-state-change
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With