Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call remove hosts on vagrant halt #56

Closed
utrotzek opened this issue Dec 15, 2013 · 3 comments
Closed

call remove hosts on vagrant halt #56

utrotzek opened this issue Dec 15, 2013 · 3 comments

Comments

@utrotzek
Copy link

Hi,

I'd suggest to call the hosts cleanup task also on vagrant halt in addition to vagrant destroy. Because if the vm is down, the host entries don't make sense (in my opinion)

This would be similar to vagrant's core behaviour for the host entry.

Thanks for sharing this ext! ;)

kind regards

@pbitty
Copy link
Contributor

pbitty commented Jan 1, 2014

Hi @weed0r23, unfortunately this is not doable in a reliable way because vagrant doesn't distinguish between machine states when giving us the list of machines that we put in the hosts file. Vagrant only distinguishes between 'created' and 'not created'. So even if we had a task set up on vagrant halt we would still get the same list of machines from vagrant.

While there is a way to query the machine state (as you can see when you run vagrant status), each vagrant provider is free to return its own state string, eg. virtualbox returns 'running', while rackspace returns 'active'.

I'm closing this for now, but feel free to reopen if you find a solution and you want to discuss it.

@arm4b
Copy link

arm4b commented Aug 4, 2014

While there is a way to query the machine state (as you can see when you run vagrant status), each vagrant provider is free to return its own state string, eg. virtualbox returns 'running', while rackspace returns 'active'.

Maybe it's possible to add at least partial support for some well-known or frequently used down statuses. Here is my example:

vagrant up status:

D:\Work>vagrant status
Current machine states:

default                   running (virtualbox)

vagrant halt status:

D:\Work>vagrant status
Current machine states:

default                   poweroff (virtualbox)

vagrant suspend status:

D:\Work>vagrant status
Current machine states:

default                   saved (virtualbox)

@krak3n
Copy link

krak3n commented Jun 19, 2015

https://github.com/cogitatio/vagrant-hostsupdater - seems to handle it fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants