cloud-init: using cicustom yaml file sets hostname to ubuntu?

dtseiler

New Member
May 31, 2025
3
0
1
proxmox/cloud-init newbie here. I've spent all day getting Terraform setup with the Telmate proxmox provider. However I wanted to go a step further and get the qemu-guest-agent installed and started right away as well. I saw the cleanest way to do that was to use a cicustom yaml file to tell it to install the package and then run the commands to enable/start it. This works great, however I noticed when I changed my Terraform to use `cicustom` instead of the previous case of just specifying `ciuser` etc, that the hostname of the VM is just `ubuntu`, whereas before it had been set to match the name of the VM as specified in my Terraform `"proxmox_vm_qemu.name` value.

The reason this is bugging me is that I'm deploying a cluster and have each node suffixed with its cluster index (eg node-01, node-02, etc). I can set a static hostname in the cicustom yaml file but that's not really any better, I'd really like to having those index values in the hostname like I did before.

I tried setting `preserve_hostname: true` in the cicustom file but that had no change that I could see.
 
Update: My non-clever way through this so far is creating a separate cicustom yaml file for each of the 5 nodes, with the desired hostname of that node. Not great but it's got me where I need to be.

However I'm curious why the hostname was set to the VM name earlier when I was still using cloud init but not a cicustom file, and if/how I can get that behavior back but still use that file so that I can cleanly install qemu-guest-agent. Before using the cicustom file, I had been adding an SSH key pair and setting up a remote-exec provisioner to manually update the packages and then install and start qemu-guest-agent.
 
If I'm understanding that correctly, I'd be creating a different metadata file for each VM? That doesn't seem much better than what I'm doing now, although I wouldn't be duplicating all the other info, so slightly cleaner.

Is the idea that I'm generating those metadata files in the terraform resource?
 
Here is something you can try:
A) create a simple VM with only PVE CI configuration. Boot it, then manually mount the CDrom and examine the files.
B) create the VM through whatever means you use, repeat the same steps.

Compare where the hostname is coming from. Then examine the CI boot log of each to see what each step does and when.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox