Skip to content

Instantly share code, notes, and snippets.

@cwholt
Created November 4, 2011 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwholt/1340782 to your computer and use it in GitHub Desktop.
Save cwholt/1340782 to your computer and use it in GitHub Desktop.
chef script to get all ipv4 address from all nodes
addresses = Array.new
search(:node).each do |n|
n[:network][:interfaces].each do |eth,eth_config|
next unless eth_config[:addresses]
eth_config[:addresses].each do |address,details|
addresses << address if details[:family] == "inet" && address != "127.0.0.1"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment