Disabling cloud-init if metadata server cannot be reached

cloud-init

I'm trying to get cloud-init to not take any action if the metadata server cannot be reached. If cloud-init ignores the error and continues executing (which seems to be the default configuration), then it resets the host SSH key, administrative user password, etc., which is a problem if the virtual machine was being used already beforehand (if password login was configured, then users can no longer access the VM).

I'm seeing this problem in two situations:

  • The metadata server goes down
  • Software is installed that blocks connections to the metadata server during boot (most recently, seeing this with ubuntu-desktop)

Best Answer

Ah, I figured it out, the reason that it's continuing executing despite not successfully reaching any data sources is because the Fallback/None data source was configured in /etc/cloud/cloud.cfg.d/90_dpkg.cfg

I deleted this file and configured in /etc/cloud/cloud.cfg:

datasource_list: [ OpenStack, Ec2 ]

And then it no longer executes.

Related Topic