Created
November 20, 2012 23:26
-
-
Save paulmooring/4121981 to your computer and use it in GitHub Desktop.
Getting addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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