amazon-web-servicescentoshostnamecloud-init

How do I stop cloud-init from overwriting my hostname on AWS (CentOS)


I have a script that runs at boot (via rc.local) and sets my hostname based on the instance name it queries from the AWS CLI. It works, and at the end of the boot log it says " login:"

At figured that cloud-init was overwriting my hostname, so I:

But in the cloud-init logs I still see "Running module update-hostname" and " Migrated semaphore update_hostname.always to config-update-hostname with frequency always", and a minute or two after boot the hostname returns to the AWS default.

What is going on? How do I stop it?


Solution

  • My really nasty hack-around is to create a cron job that sets the hostname every minute. Improved suggestions appreciated.