Check if machines are ready for SSH communication.

This commit is contained in:
Shawn Dahlen 2013-04-04 16:52:12 -04:00
parent e08fc6a811
commit 5865b1ac27
3 changed files with 10 additions and 4 deletions

View File

@ -39,10 +39,12 @@ module VagrantPlugins
# copy the hosts file to each matching machine # copy the hosts file to each matching machine
# TODO append hostname to loopback address # TODO append hostname to loopback address
matching_machines.each do |machine| matching_machines.each do |machine|
if machine.communicate.ready?
env[:ui].info @translator.t('update', { :name => machine.name }) env[:ui].info @translator.t('update', { :name => machine.name })
machine.communicate.upload(path, '/tmp/hosts') machine.communicate.upload(path, '/tmp/hosts')
machine.communicate.sudo("mv /tmp/hosts /etc/hosts") machine.communicate.sudo("mv /tmp/hosts /etc/hosts")
end end
end
@app.call(env) @app.call(env)
end end

View File

@ -1,5 +1,5 @@
module VagrantPlugins module VagrantPlugins
module HostManager module HostManager
VERSION = '0.0.2' VERSION = '0.0.3'
end end
end end

View File

@ -5,6 +5,10 @@ echo "[server1] /etc/hosts file:"
vagrant ssh server1 -c 'cat /etc/hosts' vagrant ssh server1 -c 'cat /etc/hosts'
echo "[server2] /etc/hosts file:" echo "[server2] /etc/hosts file:"
vagrant ssh server2 -c 'cat /etc/hosts' vagrant ssh server2 -c 'cat /etc/hosts'
vagrant halt
vagrant up
vagrant destroy server1 -f vagrant destroy server1 -f
echo "[server2] /etc/hosts file:" echo "[server2] /etc/hosts file:"
vagrant ssh server2 -c 'cat /etc/hosts' vagrant ssh server2 -c 'cat /etc/hosts'