[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
#cloud-config
fqdn: foo.bar.cloud
timezone: Europe/Stockholm
manage_etc_hosts: false
ssh_authorized_keys:
  - ssh-rsa AAAA...

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

1)
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.


2)
The created /etc/hosts file contain wrong IP information.
It says:
127.0.1.1       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
10.0.3.0/24, 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 10.0.3.4 when creating the
AMI).

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


3)
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
127.0.0.1       <fqdn>       <hostname>
127.0.0.1       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 127.0.0.1.
Only do this the first time the EC2 is booted. After that, the file is
managed manually.


Reply to: