No matter what I changed, something kept setting the hostname on my vm to federate.cloudlab.freeipa.org.novalocal. Even forcing the /etc/hostname file to be uneditable did not prevent this change. Hunting this down took far too long, and here is the result of my journey.
A few releases ago, I had a shell script for spinning up new virtual machines that dealt with dhclient resetting values by putting overrides into /etc/dhclient.conf. Find this file was a moving target. First it moved into
Then to a file inside
And so on. The change I wanted to make was to do two things:
- set the hostname explicitly and keep it that way
- Use my own dnsserver, not the dhcp managed one
Recently, I started working on a RHEL 7.1 system running on our local cloud. No matter what I did, I could not fix the host name. Here are some of the things I tried:
- Setting the value in /etc/hostname
- running hostnamectl set-hostname federate.cloudlab.freeipa.org
- Using nmcli to set the properties for the connections ipv4 configuration
- Explicitly Setting it in /etc/sysconfig/network-scripts/ifcfg-eth0
- Setting the value in /etc/hostname and making hostname immutable with chattr +i /etc/hostname
Finally, Dan Williams (dcbw) suggested I look in the journal to see what was going on with the host name. I ran journalctl -b and did a grep for hostname. Everything looked right until…
Mar 26 14:01:10 federate.cloudlab.freeipa.org cloud-init: [CLOUDINIT] stages.py[DEBUG]: Running module set_hostname (<module 'cloudinit.config.cc_set_hostname' from '/usr/lib/python2.7/site-packages/cloudinit...
But…I thought that was only supposed to be run when the VM was first created? So, regardless of the intention, it was no longer helping me.
yum erase cloud-init
And now the hostname that I set in /etc/hostname survives a reboot. I’ll post more when I figure out why cloud-init is still running after initialization.