I am building proxmox images with packer and I am including cloud-init with those images. No matter what I set in the cloud-config the hostname is always overwritten by the proxmox cloned template name. As well as the user ubuntu is created. The cloud-Init documentation says that if another user is created the default user won’t be. I’m my case the user in my cloud-config is created and then right after that the default ubuntu user is created as well with a higher uid and gid which leads me to believe something else is making these changes. Is proxmox overwriting these things? I can’t find very many forum post any where with people with this issue. Am I messing up something very basic or do most people not care about this? Should I worry about this or should I just make an Ansible playbook to change preserve_hostname: true and another to remove the user ubuntu.
Try to comment the default user in both locations in the cfg.
I would also give this video a watch. User part starts around 6:14, but I’d say watch it whole.
Around 20:13 there’s also some small trivia, but I’m not sure if it applies.
I’m not a user of cloud-init, but my guts always tell me to go to the logs. Can you check what logs cloud-init is using, and paste the snippets since you clone the VM from the template in a pastebin and send us the link? I want to see if the default user is part of your image, or if the user is created by cloud-init proxmox service. You might also have a cloud-init log on a cloned VM from a template, that could also be useful.
IIRC, there’s two options you have to set for the hostname. Setting only one of them doesn’t tend to work. I think I had both of them shown in the cloud-init video, but I honestly don’t remember.
Actually, I found it:
The first option is telling cloud-init what the hostname should be, the second option is telling cloud-init that you want it to manage the hostname in the first place. Seems redundant to me, but that’s how I got it to work.
Proxmox will also override the hostname with whatever name you gave the VM (assuming you have Proxmox cloud-init enabled for the VM).
Thank you very much I really appreciate the help! Ultimately I discovered it was my own fault. I learned there is a very big difference between cloud-config and cloud-config autoinstall for Ubuntu I misunderstood and thought they were the same so I wasn’t adding config into the cloud-init section in proxmox so proxmox thought that there was no user. I really appreciate the help again!
Thank you so much for the help and response! You have no idea how big a help your videos are thank you! It turned out it was my fault. I didn’t know the confusing difference between cloud-config and cloud-config autoinstall for Ubuntu. One thing I did find was that if I set a search domain with cloud-init and set an fqdn hostname it seems to stay but we’ll see hahaha. Thank you again!
Happy to help!
cloud-init can be a bit complicated sometimes, but it’s worth it.