Cloud-Init: Set-Hostname Question

0xBEN

Member
May 6, 2020
13
0
21
Greetings,

I'll keep it short and to the point. I made an observation when doing some experimenting with cloud-init.
I first started experimenting with cloud-init on CentOS 8.

Here's the issue I encountered and on which I seek any advice or experiences from other users:

On any RHEL-based distro, /etc/hostname does not reflect the Proxmox VM name.
  • Tested on:
    • CentOS 8
    • Fedora Workstation and Server
However, on any Debian-based distro, /etc/hostname does reflect the Proxmox VM name.
  • Tested on:
    • Debian Buster
    • Kali
    • Ubuntu Desktop
I'll spare the extraneous information, but I followed the exact same process for both situations.
So, the only conclusion I could come to is that it is based on a limitation of the underlying distribution.
Does anyone else on the forum share a similar experience or know of a workaround?
 
Have you checked the cloudinit config inside the VM?
 
mira,

Thank you for the reply.
Yes, I did try making several adjustments to the /etc/cloud/cloud.cfg file in the template VM.
If I added hostname: <name> or fqdn: <name> to the configuration file, it would be applied to the clone.
However, this seems to defeat the automated nature of cloud-init.
I want to avoid hardcoding any values into the config to any extent possible.
 
mira,

Thank you for taking the time to work through that and reproduce the issue.

I also came across that thread during my search for answers, but decided to post on Proxmox forum, as that is the cloud-init platform being used in my case.

Seems like there are no feasible next steps, then. Oh well, I do certainly appreciate your time.
 
I'm using the GenericCloud 8.2 image from:

https://cloud.centos.org/centos/8/x86_64/images/

and it seems to be working as I expected.

In particular, I was able to change the hostname in the Proxmox options, and, after a reboot, it was configured inside the virtual machine.
The same for configuring a static IP address in the cloud-init tab of Proxmox.

Best regards,
 
  • Like
Reactions: 0xBEN
I'm using the GenericCloud 8.2 image from:

https://cloud.centos.org/centos/8/x86_64/images/

and it seems to be working as I expected.

In particular, I was able to change the hostname in the Proxmox options, and, after a reboot, it was configured inside the virtual machine.
The same for configuring a static IP address in the cloud-init tab of Proxmox.

Best regards,

Thank you for following up here with your findings! I'll give it a whirl and see if I can reproduce on my end.