Skip to content

Instantly share code, notes, and snippets.

@msabramo
Created April 13, 2012 15:13
Show Gist options
  • Select an option

  • Save msabramo/2377571 to your computer and use it in GitHub Desktop.

Select an option

Save msabramo/2377571 to your computer and use it in GitHub Desktop.
A crude way of getting all of the host-only IP addresses I've used for vagrant vms
#!/usr/bin/env ruby
require 'find'
def process_vagrantfile(vagrantfile)
box = nil
f = File.open(vagrantfile).each do |line|
if match = /^\s*config\.vm\.box = "([^"]+)"/.match(line) then
box = match[1]
end
if match = /^\s*config\.vm\.network :hostonly, "([^"]+)"/.match(line) then
puts "#{match[1]} #{box}"
end
end
end
Find.find(ENV["PWD"]) do |path|
if path.end_with? "Vagrantfile" then
process_vagrantfile path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment