Ubuntu cloud-init on Proxmox

U

While setting up a cloud-init template for use on a Proxmox cluster I ran into a few small problems caused by the default Ubuntu 20.04 installation. Since Ubuntu is configured initially after a fresh install using cloud-init, it runs only once, even after running cloud-init clean.

To get around this issue, purge all existing cloud-init files are reinstall it.

apt purge cloud-init
rm -rf /etc/cloud
rm -rf /var/lib/cloud
apt install cloud-init

Now, configure your /etc/cloud/cloud.cfg and after a clone and reboot, the init process should run again.

The next problem has to do with DHCP assignment. For some reason, Ubuntu 20.04 (and possibly earlier versions) do not use the MAC address of your network interface for DHCP assignment, instead, it uses the UUID that exists in /etc/machine-id.

To fix this we need to make sure that the machine-id file is empty as well as create a symlink to another instances of this same UUID.

rm /etc/machine-id
rm /var/lib/dbus/machine-id
touch /etc/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

On next boot, Ubuntu will create a new UUID and DHCP will work as expected.

Add Comment

Benjamin Phelps

Get in touch

You can find me in various places with various levels of success. Your best bet is just to send me an email (send it to ben at this domain).