Skip to content

Instantly share code, notes, and snippets.

@Hounddog
Created April 14, 2015 18:25
Show Gist options
  • Save Hounddog/11bce9f6f41e4cebe109 to your computer and use it in GitHub Desktop.
Save Hounddog/11bce9f6f41e4cebe109 to your computer and use it in GitHub Desktop.
Vagrant Proxy
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Read YAML file with box details
servers = YAML.load_file('servers.yml')
#ARGV
skip = 0
while skip < ARGV.length
if ARGV[skip].start_with?(arg='--vagrant-namespace=')
v = ARGV.delete_at(skip).dup
v.slice! arg
namespacefilter = v.to_s # set namespace
else # skip over "official" vagrant args
skip = skip + 1
end
end
servers.each do |servers, i|
count = servers['count']
(1..count).each do |i|
h = "#{servers['namespace']}-#{i}"
if namespacefilter == servers['namespace']
ARGV << h;
end
end
end
myargs = ARGV.join(" ");
exec 'vagrant ' << myargs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment