vagrant-hostmanager
vagrant-hostmanager copied to clipboard
vagrant-hostmanager support for multi-machine Vagrantfile?
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?
@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?
Thx @bibstha this helped me a lot!
@rameshdharan is there a reason why you have two machines with the same host name?
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.