As far as I can see, cloud-init
runs every time the config changes. Not just the very first time the system boots, but every time the provided configuration changes. This makes somewhat sense, as I guess it's hard to define the "first time" (the cloned VM already ran before being frozen and used as template, so it's never really the first time). However, I've—from time to time, quite rarely, but still—found that cloud-init
re-runs on already provisioned system when they reboot.
Some steps, however, seem to screw up the setup when cloud-init
is run on a fully configured system. For example, if it is run one more time after the initial setup and cloud-init
sets some configuration to value X
, but you had it manually overridden afterwards to Y
and now cloud-init
re-runs to set it back to X
. Or, have the system recreate your SSH host keys.
I've thus found it quite useful to manually run:
sudo touch /etc/cloud/cloud-init.disabled
...after the initial setup to prevent it from ever running cloud-init
again. (In cases, where cloud-init
really is only used for an initial "clone & set IPs/hostname" kind of configurations.)
But is there any way to automate this? Like adding some parameter to the /etc/cloud/cloud.cfg
that disabled itself after the next run?