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 -f doesn't work after setting vm.hostname on CentOS 7 #4784

Closed
sds opened this issue Nov 5, 2014 · 3 comments
Closed

hostname -f doesn't work after setting vm.hostname on CentOS 7 #4784

sds opened this issue Nov 5, 2014 · 3 comments

Comments

@sds
Copy link

sds commented Nov 5, 2014

With Vagrant 1.6.5, using the following Vagrantfile:

Vagrant.configure("2") do |c|
  c.vm.box = "opscode-centos-7"
  c.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.0_chef-provisionerless.box"
  c.vm.hostname = "some-domain.vagrantup.com"
end

Running vagrant up followed by vagrant ssh -c "hostname --fqdn" outputs:

hostname: Name or service not known

Whereas for a Vagrantfile for some other OS (Ubuntu in this case):

Vagrant.configure("2") do |c|
  c.vm.box = "opscode-ubuntu-13.10"
  c.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box"
  c.vm.hostname = "some-domain.vagrantup.com"
end

...the same steps would output:

some-domain.vagrantup.com

I'm not sure if this falls under the purview of the Vagrant project, but the way it manifests itself is that our tests via the test-kitchen project fail due to the node['fqdn'] attribute being nil (since it is set by running hostname --fqdn).

It seems like setting a hostname should result in the VM having a FQDN (which is usually accomplished by adding an alias in /etc/hosts). Thoughts?

@gnawhleinad
Copy link
Contributor

It looks like /etc/hosts should get updated (if you adjust the vm.hostname configuration). See plugins/guests/redhat/cap/change_host_name.rb.

I think I'm running into a similar issue where the hostname is partially updated and not on /etc/hosts (the output of hostname is correct). If I manually edit /etc/hosts the output of hostname --fqdn is correct.

@Xylakant
Copy link
Contributor

This is a bug in Vagrant 1.6.5, a fix has been provided and merged in #4465, but no new version has been released. I have a monkeypatch that does the same in https://github.com/Asquera/vagrant-patches. It's a bit rough and YMMV, but I'm accepting feedback :)

@sds
Copy link
Author

sds commented Dec 11, 2014

Thanks for the heads up about #4465, @Xylakant.

Looks like this has been fixed in 1.7.0.

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

No branches or pull requests

3 participants