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

Execution of hostmanager during vagrant reload

Open papadi opened this issue 8 years ago • 6 comments

hostmanager isn't executed when I run vagrant reload. It does work if I execute it manually after vagrant reload by running vagrant hostmanager. Any ideas? Can I make it run during reload too? There is a chance, when using DHCP, that the IP will change during a reload.

papadi avatar Apr 08 '16 08:04 papadi

Thank you for the question @papadi - currently vagrant-hostmanager is not invoked during a vagrant reload. Given that a vagrant reload is equivalent to a vagrant halt followed by a vagrant up this would not violate configuration vs state. Please submit a pull request with your proposal.

seth-reeser avatar Apr 13 '16 14:04 seth-reeser

I'm using Vagrant with HyperV and external network. In this case there is no option other than DHCP and there are cases, when I do Vagrant Reload that the IP of my VM changes. I will take a look at the code and I will see if I can do anything about that pull request. I'm afraid I don't feel confident though! :)

papadi avatar Apr 14 '16 20:04 papadi

I have this issue as well, in my case it's with the vagrant aws provider tho. Every time I do a vagrant reload, the IP of my aws instance changes and I have to readjust the hosts file manually.

Would love to submit a pull request, but also do not feel confident enough to tackle this just yet.

madsem avatar May 04 '16 19:05 madsem

I ended up creating a batch file for this.

papadi avatar May 04 '16 21:05 papadi

It would be great to have this issue fixed. For instance, in Homestead (the VM for PHP Laravel), you can add new sites (virtual hosts) by adding 2 lines to a yaml file, and the documentation states that you just have to run vagrant reload --provision. However, the hosts file does not get updated. In order to make it work, you have to run:

vagrant halt
vagrant up --provision

cheoAlejo avatar Nov 18 '18 02:11 cheoAlejo

Seems this works :)

config.hostmanager.enabled = true
config.vm.provision :hostmanager, run: 'always'

LastDragon-ru avatar Apr 04 '20 19:04 LastDragon-ru