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.

[root@collector ~]# hostname -f

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

[root@collector ~]# vim /etc/cloud/cloud.cfg

Comment out the below line:

# - update_hostname

Now if you change the hostname and reboot:

[root@collector ~]# hostnamectl set-hostname
[root@collector ~]# reboot

Your hostname should remain in-place:

[root@collector ~]# hostname -f

Method 2

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

[root@collector ~]# 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