cloud-init not working when changing name of VM after clone

jwinslow

New Member
Jun 1, 2021
1
0
1
43
I followed the instructions here -> https://pve.proxmox.com/wiki/Cloud-Init_Support to create a ubuntu 2004 template using the cloudimg https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img

Running the following commands works consistently:
Code:
qm clone 2004 100 --name cloudinit-test
qm set 100 -cipassword highlysecure123 -ciuser max -sshkeys /root/.ssh/id_rsa.pub
qm start 100

When I watch the console as the VM boots, I see the hostname is set to "cloudinit-test" properly, and the ciuser/cipassword allows me to login.

However, when I set the name of the VM using the `--name` argument to the `qm` command, cloud-init no longer works:
Code:
qm clone 2004 100 --name cloudinit-test
qm set 100 -cipassword highlysecure123 -ciuser max -sshkeys /root/.ssh/id_rsa.pub --name 59
qm start 100

The hostname is no longer set properly and the ciuser/cipassword does not allow me to login to the cloned VM.

In addition, I am experiencing this behavior inconsistently when using an OVMF BIOS with an EFI drive attached (I will open a separate issue for that).
 
That's a cloud-init issue. if you take a look at the log (/var/log/cloud-init.log) in the VM you can see that an error is generated because there's no `find` method on an `int` in python.
As a workaround you have to use at least one non-digit character it seems.