Open rthomas opened 9 years ago
I believe I have found the root cause here, which is the usage of active_machines
here: https://github.com/smdahlen/vagrant-hostmanager/blob/8ec6108143a6cbf9f9ac839ad9124b92a9b9d881/lib/vagrant-hostmanager/action/update_all.rb#L31
From the Vagrant docs, active_machines
is:
Returns a list of machines that this environment is currently managing that physically have been created.
An "active" machine is a machine that Vagrant manages that has been created. The machine itself may be in any state such as running, suspended, etc. but if a machine is "active" then it exists.
So this will return the set of machines that have been created, but will also include those in the poweroff
state
Same problem here.
Same here
I believe the problem shows up if you have a custom ip_resolver which most people would since the normal ip_resolver just looks at the ssh_config. With a custom ip_resolver, you just have to catch the exception when trying to ssh into the machine that is down. Here is my ip_resolver for reference:
$logger = Log4r::Logger.new('vagrantfile')
def read_ip_address(machine)
command = "LANG=en ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'"
result = ""
$logger.info "Processing #{ machine.name } ... "
begin
# sudo is needed for ifconfig
machine.communicate.sudo(command) do |type, data|
result << data if type == :stdout
end
$logger.info "Processing #{ machine.name } ... success"
rescue
result = "# NOT-UP"
$logger.info "Processing #{ machine.name } ... not running"
end
# the second inet is more accurate
result.chomp.split("\n").last
end
Vagrant.configure("2") do |config|
# ...
if Vagrant.has_plugin?("HostManager")
# ...
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
read_ip_address(vm)
end
Thanks @pykler that worked for me.
yeah wrap in begin/rescue works for me too. thanks @pykler
I have the following block in my
Vagrantfile
to only run hostmanager if it is installed:When it is installed, provisioning my boxes works fine, however if I halt them, and then do a
vagrant up
each box fails with the message below - removing hostmanager allows them to start up cleanly.I have 5 boxes in this config and each one fails at the hostmanager stage.
The box is left in an up and running state, it is just annoying to run
vagrant up
five times in order to bring up all of my boxes after a halt.