Skip to content

Instantly share code, notes, and snippets.

@pharaujo
Created June 13, 2014 15:17
Show Gist options
  • Save pharaujo/c6e87bd098266fbac14a to your computer and use it in GitHub Desktop.
Save pharaujo/c6e87bd098266fbac14a to your computer and use it in GitHub Desktop.
Get node IP addresses in Chef
# chef > addresses = node[:network][:interfaces].collect {|iface,props| props[:addresses].find_all {|x, opts| opts[:family] == 'inet'}}.find_all {|a| !a.empty?}.collect {|a| a.first.first}
# => ["127.0.0.1", "10.62.200.40", "172.31.254.1"]
addresses = node[:network][:interfaces].collect {|iface,props| props[:addresses].find_all {|x, opts| opts[:family] == 'inet'}}.find_all {|a| !a.empty?}.collect {|a| a.first.first}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment