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 146 forks source link

Execution of hostmanager during vagrant reload #185

Open papadi opened 8 years ago

papadi commented 8 years ago

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.

seth-reeser commented 8 years ago

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.

papadi commented 8 years ago

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! :)

madsem commented 8 years ago

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.

papadi commented 8 years ago

I ended up creating a batch file for this.

cheoAlejo commented 6 years ago

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
LastDragon-ru commented 4 years ago

Seems this works :)

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