Ensure one VM ("gateway") is running before allowing the others
# Check to see that we have a gateway running before we allow the `up` of another VM | |
# This is a filthy hack | |
if ARGV[0] != 'up' | |
GATEWAY_STATUS = 'running' # this is irrelevant for everything but `vagrant up` | |
# if we don't do this, we could fork forever in the else block, here | |
else | |
GATEWAY_STATUS = `vagrant status --machine-readable | grep 'gateway,state,' | awk -F, {'print $4'}`.strip! | |
if GATEWAY_STATUS != 'running' | |
puts "*** The gateway is not running. You can not 'up' any other VMs." | |
end | |
end | |
Vagrant.configure(2) do |config| | |
if GATEWAY_STATUS == 'running' | |
config.vm.define :othervm, primary: false, autostart: false do |config| | |
bootstrap config.vm # custom | |
end | |
end | |
if GATEWAY_STATUS == 'running' | |
config.vm.define :yetanothervm, primary: false, autostart: false do |config| | |
bootstrap config.vm # custom | |
end | |
end | |
config.vm.define :gateway, primary: true, autostart: true do |config| | |
bootstrap config.vm # custom | |
end | |
end |
This comment has been minimized.
This comment has been minimized.
Does it matter if the gateway is up? What you really care about is connectivity over your VPN.Though I suppose the conditional is the really ugly part. |
This comment has been minimized.
This comment has been minimized.
Ha. Just noticed your comment @nicksloan. It does matter because we run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Someone tell me why this is a bad idea, and preferably: how to do it via internal APIs. (-: