devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 148 forks source link

Merged configuration from box vagrantfiles not used #182

Open marek-obuchowicz opened 8 years ago

marek-obuchowicz commented 8 years ago

I have configured hostmanager in Vagrantfile, then packaged it into box. When I'm creating a vm using vagrant init <boxname>; vagrant up - it doesn't respect hostmanager configuration from box file.

I guess it comes from https://github.com/devopsgroup-io/vagrant-hostmanager/blob/master/lib/vagrant-hostmanager/action/update_host.rb#L13 -> it calls env[:global_env].vagrantfile which, according to documentation, "Represents the default Vagrantfile, or the Vagrantfile that is in the working directory or a parent of the working directory of this environment." - so it doesn't consider the value from merged configurations of all Vagrantfiles, just the one from file in current directory.

dkarlovi commented 8 years ago

Opened that in https://github.com/devopsgroup-io/vagrant-hostmanager/issues/131

amontalban commented 8 years ago

Hey @marek-obuchowicz / @dkarlovi,

Can you test https://github.com/amontalban/vagrant-hostmanager/commit/09ef5194085614bb8259ca61bdb214f7853b1d03 on your setup? I had same issue (Configuring vagrant-hostmanager in base box) and that fixed.

I'm not a developer and my Ruby skills are super limited but I hope it helps.

If that works I can open an PR and maybe @seth-reeser can merge it.

Thanks!

dkarlovi commented 8 years ago

@amontalban I will try it out monday and let you know, thanks.

dkarlovi commented 8 years ago

@amontalban I'm sorry about this taking quite so long, but I do confirm that it does in fact work, I've removed

config.hostmanager.enabled = true
config.hostmanager.manage_host = true

from my (thin) project Vagrantfile and

Please, create a PR so we can get this fixed. Thank you, great job!

amontalban commented 8 years ago

@dkarlovi Sorry for the long delay, sure let me push a PR.

Thanks!

amontalban commented 7 years ago

@dkarlovi I'm seeing that this is broke again with Vagrant 1.9

Working on a fix.

Sorry, it works it seems that Vagrant have an issue when installing plugins from remote repositories. Check mitchellh/vagrant#8210.

For now you can download this patched plugin and install it with: vagrant plugin install vagrant-hostmanager-1.8.5.gem

You can download it from: https://packagecloud.io/amontalban/vagrant-hostmanager/packages/gems/vagrant-hostmanager-1.8.5.gem