vagrant-hostmanager icon indicating copy to clipboard operation
vagrant-hostmanager copied to clipboard

Merged configuration from box vagrantfiles not used

Open marek-obuchowicz opened this issue 9 years ago • 6 comments
trafficstars

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.

marek-obuchowicz avatar Mar 19 '16 18:03 marek-obuchowicz

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

dkarlovi avatar May 18 '16 07:05 dkarlovi

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!

amontalban avatar Jul 08 '16 13:07 amontalban

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

dkarlovi avatar Jul 08 '16 19:07 dkarlovi

@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

  • [x] vagrant hostmanager updates /etc/hosts, adding the entry
  • [x] vagrant destroy updates /etc/hosts, removing the entry
  • [x] vagrant up updates /etc/hosts, adding the entry

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

dkarlovi avatar Jul 26 '16 11:07 dkarlovi

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

Thanks!

amontalban avatar Aug 11 '16 21:08 amontalban

~~@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

amontalban avatar Jan 17 '17 13:01 amontalban