CentOS 7 /etc/hosts vs /etc/cloud/templates/hosts.*.tmpl?

August 26, 2015 4.7k views
Getting Started Networking

If I create a CentOS 7 droplet using the default DO-supplied image, I note when going to /etc/hosts to add private IP aliases for my other droplets that there’s this:

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data

If I look at /etc/cloud/templates/ I see three hosts.OSflaver.tmpl files: debian, redhat, and suse. I tried adding my aliases to all three not knowing/caring which is being sourced and rebooted the droplet. Nothing.

I add the entries directly to /etc/hosts and reboot, they stick despite the warning.

Inspecting /etc/cloud/cloud.cfg reveals some DigitalOcean configuration? Not sure if I need to or should attempt to disable manage_etc_hosts as suggested in the hosts comments, figure out how to use the templates, or what?

Anyone have any advice? For now I’m just using /etc/hosts and ignoring the warning comments. So far it seems okay but it’s likely not.

1 Answer
Have another answer? Share your knowledge.