Hostname Persistence on OpenStack

You may notice when using OpenStack, if you change the hostname, that change is not persistent over a reboot. This is because cloud-init updates the hostname on start-up.

Method 1

One method would be to simply prevent cloud-init from updating the hostname and manually changing it yourself.

[[email protected] ~]# hostname -f

To make your hostname change survive a reboot, edit /etc/cloud/cloud.cfg:

[[email protected] ~]# vim /etc/cloud/cloud.cfg

Comment out the below line:

# - update_hostname

Now if you change the hostname and reboot:

[[email protected] ~]# hostnamectl set-hostname
[[email protected] ~]# reboot

Your hostname should remain in-place:

[[email protected] ~]# hostname -f

Method 2

A second method would be to configure cloud-init to set the hostname for you.

[[email protected] ~]# vim /etc/cloud/cloud.cfg.d/99_hostname.cfg

Enter the following content:

hostname: collector

Reboot and check.

Be the first to comment

Leave a Reply