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
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
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.
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.