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

Hostname not added to /etc/hosts on CentOS 7.0 #4465

Closed
biemond opened this issue Sep 5, 2014 · 6 comments
Closed

Hostname not added to /etc/hosts on CentOS 7.0 #4465

biemond opened this issue Sep 5, 2014 · 6 comments

Comments

@biemond
Copy link

biemond commented Sep 5, 2014

Hi,

I am using vagrant 1.6.5 and this fixed some of my CentOS 7.0 issues.
It sets the hostname ( I checked with uname -a ) and also my private network device is created.

but my /etc/hosts file is not updated with the FQDN, in CentOS6.5 this works perfectly

 [root@admin ~]# cat /etc/hosts  
 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Vagrantfile

admin.vm.hostname = "admin.example.com"
admin.vm.network :private_network, ip: "10.10.10.10"

Thanks

@andytson
Copy link
Contributor

andytson commented Sep 5, 2014

It was incorrectly assumed in #4352 that hostnamectl set-hostname would set everything that the pre-centos/rhel 7.0 process previously did

  1. Update sysconfig
  2. Update hostname via sudo hostname
  3. Update /etc/hosts
  4. Update DHCP_HOSTNAME in /etc/sysconfig[/network-scripts/ifcfg-*]
  5. Restart networking.

I believe what was the equivalent to 1 and 2 is definitely done by hostnamectl (its set for the current session and is still there on restart), I'm unsure of whether 4 (and therefore 5) is needed, but 3. Update /etc/hosts definitely isn't done by hostnamectl

@mitchellh
Copy link
Contributor

This is the reason I asked but it looks like I got the wrong answer. Got it.

@mitchellh
Copy link
Contributor

Thanks for the report!

@Xylakant
Copy link
Contributor

I was trying to take a stab at fixing this, but alas, since I use the vmware fusion plugin I failed after jumping through a long series of hoops since the plugin does not work with development versions of vagrant.

Xylakant added a commit to Asquera/vagrant that referenced this issue Sep 20, 2014
the previous fix for hashicorp#4465 assumed that the NetworkManager takes care of updating /etc/hosts with
the new hostname, but testing shows it doesn't. This change ensures that the change is always added
to /etc/hosts when the name changes.
@andytson
Copy link
Contributor

I think there's some inconsistency in the usage of the DHCP hostname across guests. Only the redhat < 7 and the pId guests appear to set this, which is either that the other guests magically set this automatically, or the people who provided the PRs only considered their choice distribution for the features

@Xylakant
Copy link
Contributor

I must admit I never used DHCP to configure the private/public network adapters, so I have no test setup. According to some info setting DHCP_HOSTNAME is not required when NetworkManager is used, but the RHEL documentation is pretty thin on that issue. It's be easy to adapt the PR, though.

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

No branches or pull requests

4 participants