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

vagrant-hostmanager support for multi-machine Vagrantfile? #179

Open
rameshdharan opened this issue Mar 3, 2016 · 4 comments
Open

vagrant-hostmanager support for multi-machine Vagrantfile? #179

rameshdharan opened this issue Mar 3, 2016 · 4 comments

Comments

@rameshdharan
Copy link

Wondering if it’s possible to make vagrant-hostmanager play nicely with a multi-machine config, i.e. something like the form:

Vagrant.configure('2') do |config|
  config.vm.define "default", primary: true do |default|
     default.vm.hostname = "foo"
     default.hostmanager.enabled = true
     default.hostmanager.manage_host = true
     default.hostmanager.aliases = "bar"
     ...
  end

  config.vm.define "alternate", autostart: false do |alternate|
     alternate.vm.hostname = "foo"
     alternate.hostmanager.enabled = true
     alternate.hostmanager.manage_host = true
     alternate.hostmanager.aliases = "bar"
     ...
  end

I've tried the above with vagrant 1.7.4 and hostmanager 1.6.1 and found that the /etc/hosts entries are clobbering each other and not correct. Wondering if this is just because I'm doing it wrong, or if this type of thing is not actually supported?

@bibstha
Copy link

bibstha commented Mar 10, 2016

@rameshdharan shouldn't your configuration instead be

Vagrant.configure('2') do |config|
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true

  config.vm.define "default", primary: true do |default|
     default.vm.hostname = "foo"
     default.hostmanager.aliases = "fancy-name-foo"
     ...
  end

  config.vm.define "alternate", autostart: false do |alternate|
     alternate.vm.hostname = "bar"
     alternate.hostmanager.aliases = "fancy-name-bar"
     ...
  end

Does this fix it for you?

@czerasz
Copy link

czerasz commented Mar 14, 2016

Thx @bibstha this helped me a lot!

@seth-reeser
Copy link
Member

@rameshdharan is there a reason why you have two machines with the same host name?

@primozcigler
Copy link

I figured this out by trial and error and I would love someone confirm: config.hostmanager.enabled = true will work only if configured at the topmost level.

So this will work: config.hostmanager.enabled = true

And this will not: somenode.hostmanager.enabled = true

If this is the case and correct, it would be great to include in the docs, as it might save people like me hours of debugging.

Thank you.

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

No branches or pull requests

5 participants