- Custom Cloud-Init configuration
As stated in Proxmox Doc, you can create a custom Cloud-Init config where you’re free to set all parameters you need in a snippet yaml file, then generate a Cloud-Init custom image
This file is static and whatever hostname you define there, it will be used during VM deployment
Proxmox has a nice GUI with a (limited) set of cloud-init attributes you cloud set there. I’m referring to this GUI:
Under the hood, configuration defined there is stored as a snippet to generate Cloud-Init custom image (with User config)
In Proxmox source code, I found that Promox on the fly is overriding the hostname (and – in some cases fqnd) based on the VM name and DNS Domain (domain taken from from Cloud-Init UI DNS Domain field)
Note, in Proxmox 8 there is a fix to improve retrieving hostname and fqdn; I believe before the fix it was necessary to define VM name as fqdn – now it seems not needed anymore.
Here is the catch: if you define your custom Cloud-Init User (and only user) config through
qm set 9000 --cicustom "user=<volume>,network=<volume>,meta=<volume>"whole setup defined in the GUI Cloud-Init window + dynamic update of the hostname is just ignored (and only custom yaml /with static hostname/ from snippets is used);
This is a bit crippled, I’d expect a procedure where GUI Cloud-Init settings are combined with snippet yaml (taking GUI config with precedence).
With my limited experiences, here is my flow:
I gave up on pre-built cloud-init images – as they need tons of customizations through snippet yamls to get to the shape I want. Possible, of course, but then we are stuck with a static hostname.
Instead of this, I just installed Ubuntu 22.04 LTS VM, logged in, ran all my custom changes manually (TZ, installed needed packages, …) then cleaned up and prepared the VM before converting this VM into the Template using this link. Of course – no custom Cloud-Init yaml as I want hostname to be updated by Proxmox.
Finally, I can quickly spin up a VM. But I must say – this could have been documented better.