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 collector.novalocal
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:
cloud_init_modules: ... # - update_hostname ...
Now if you change the hostname and reboot:
[root@collector ~]# hostnamectl set-hostname collector.pikedom.com [root@collector ~]# reboot
Your hostname should remain in-place:
[root@collector ~]# hostname -f collector.pikedom.copm
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:
#cloud-config hostname: collector fqdn: collector.pikedom.com
Reboot and check.
Be the first to comment