Cloud init is the ubiquitous first-run config software used by most cloud providers. Recently I was messing with it trying to get some configuration to work, it’s always been a tool that requires a lot of fiddling. I wanted to write down my tips for debugging cloud init.
First and foremost
It says this on the website but the most common reasons the cloud-init user data isn’t working are these two reasons:
- YAML formatting problem
#cloud-configmissing from the top of the file
You can disable cloud init by passing
cloud-init=disabled on the kernel command line.
After ssh in, locally reproduce
It’s a lot faster to debug and iterate with a running system than to re-launch a vm.
Reset all the state and re-run cloud init (warning this will regen ssh keys)
cloud-init clean cloud-init init
More manual and leaves bits around to inspect
Your actual user data
Re run a single module from cloud-init/cloud-config
cloud-init single --name foobar
Inspect cloud-init from a different script
The docs say you can poll on
cloud-init status if you want to wait for cloud-init to finish
# cloud-init status --long status: running time: Wed, 02 Dec 2020 22:53:49 +0000 detail: DataSourceNoCloudNet [seed=/dev/vdb][dsmode=net]
Inspect ConfigDrive/NoCloud manually
# mkdir /media/b # mount /dev/vdb /media/b mount: /media/b: WARNING: device write-protected, mounted read-only. # ls /media/b/ meta-data user-data vendor-data