[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#949735: AWS Debian9 AMI: Problems with /etc/hosts when user-data set 'manage_etc_hosts: false'

Package: cloud.debian.org

I setup an EC2 in AWS using the Debian 9 AMI.
I pass along this user-data:
cat /var/lib/cloud/instance/user-data.txt
fqdn: foo.bar.cloud
timezone: Europe/Stockholm
manage_etc_hosts: false
  - ssh-rsa AAAA...

Sure enough, /etc/hosts is not managed. But...

The created /etc/hosts file give confusing and conflicting information.
It says:
# 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.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data

This is wrong. I have configured it as 'false'.
I guess this erroneous information come from some default /etc/hosts
template in your AMI.

Action 1:
Please make the header state "Your system has configured
'manage_etc_hosts' as False.
Therefore this file is not managed by cloud-init." or something similar.

The created /etc/hosts file contain wrong IP information.
It says:       ip-10-0-3-4.ec2.internal        ip-10-0-3-4

This is wrong. My EC2 don't have this IP. In case I do use the subnet, this line would confuse me since I'm not the one who
added it.
Again, I guess this is left-overs from some default /etc/hosts
template in your AMI (you probably used IP when creating the

Action 2:
Please remove this line. Or actually, see 3) below.

Even if I set 'manage_etc_hosts: false' I would still like the
installed Debian EC2 machine to get an /etc/hosts similar to
a manually installed Debian machine, using netinst or CD1.
That is, I don't want /etc/hosts to be *managed* over time (after
reboots), but I *do* want the initial /etc/hosts to get the line       <fqdn>       <hostname>       localhost
...just like the normal debian-installer would do.

Action 3:
If 'manage_etc_hosts' is set to "false", do a one-time write to
/etc/hosts, setting the fqdn and hostname to
Only do this the first time the EC2 is booted. After that, the file is
managed manually.

Reply to: