Created
June 22, 2011 19:07
-
-
Save jtimberman/1040853 to your computer and use it in GitHub Desktop.
Ohai plugin to return semantic reference attributes for network addresses
This file contains 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
# This might not work on newer (than 0.10.6) versions of Chef. | |
# Thanks for pointing to my new gist, spkane :) | |
# https://gist.github.com/1040543 | |
require 'rubygems' | |
require 'ohai' | |
o = Ohai::System.new() | |
o.all_plugins | |
# And retrieve some useful semantic reference attributes for network interfaces | |
o['network']['interfaces'].each do |iface, addrs| | |
addrs['addresses'].each do |ip, params| | |
o["ipaddress_#{iface}"] = ip if params['family'].eql?('inet') | |
o["ipaddress6_#{iface}"] = ip if params['family'].eql?('inet6') | |
o["macaddress_#{iface}"] = ip if params['family'].eql?('lladdr') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just in case you stumble on this as I did, there is a more updated version of this that works in Chef 10.6 here:
https://gist.github.com/1040543