Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace entry in /etc/hosts instead of appending #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

c0deaddict
Copy link

When using kitchen-qemu in combination with cloudinit, a duplicate entry in the /etc/hosts file is created by the script. For example, this is the contents of /etc/hosts after a converge:

# 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.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 kitchen-ci.test kitchen-ci
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

127.0.0.1 new-hostname.local new-hostname

The problem is that the hostname command gives back localhost, and not new-hostname.

This PR replaces the existing hostname entry with the new hostname. I'm not 100% if this works for all Linux distros. I've tested this for Debian 8, 9 and 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants