Skip to content

Instantly share code, notes, and snippets.

@paulmooring
Created November 20, 2012 23:26
Show Gist options
  • Save paulmooring/4121981 to your computer and use it in GitHub Desktop.
Save paulmooring/4121981 to your computer and use it in GitHub Desktop.
Getting addresses
nodes = search(:node, 'name:*')
nodes.each do |node|
node['network']['interfaces'].each do |int|
addresses = node['network']['interfaces'][int[0]]['addresses']
if addresses.respond_to? :each
addresses.each do |add, details|
if details['family'] == "inet" and add =~ /172\.28\.[0-9]+\.[0-9]+/
puts "#{int[0]}: #{add}"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment