Since Cloud-Init constantly checks the configuration of the server and corrects it in case of doubt, the service must be deactivated for corresponding local changes.
- Edit the configuration file:
- The values of the parameters "preserve_hostname" and "manage_etc_hosts" must be changed as followed:
preserve_hostname: true manage_etc_hosts: false
- Now the hostname can be edited:
- To ensure a correct resolution of the hostname, the entry in the hosts file must also be updated
A corresponding entry would look like this
<IP of the server> <Full Qualified Domain Name> (10.0.0.1 myexampledomain.com)
- Finally, the system must be restarted.
- Now you should use hostname -f to check if the changes have taken effect.