I'm trying to set a hostname with hostnamectl set-hostname server.domain.tld
in CentOS 7 but when I reboot it returns to sp-30.localdomain
Always i used that command to change hostname but now is not working, so or i'm missing somethinh or is some bug?
However, how can i change permanently my hostname?
Before rebooting I check /etc/hostname file and its correct but when I reboot it reverts
"SP-30" was the name I gave to the instance in OVH public cloud.
I found that my CentOS 7 Instance uses Cloud-Init every reboot and it sets to originally given hostname every time I reboot the instance.
I found a solution here:
https://www.ovh.pt/g1928.hostname
Which tells that and to get around must have to deactivate an cloud-init module with:
manage_etc_hosts: false
in/etc/cloud/cloud.cfg
file, and then hostname to whatever you want.But since my
/etc/cloud/cloud.cfg
file was different I just deleted:under
cloud_init_modules
and it worked for meNot sure about CentOS, but I also ran into this problem on Ubuntu Server. Resolved with: