Skip to content

Instantly share code, notes, and snippets.

@trilom
Forked from jtimberman/network_addr.rb
Last active December 9, 2018 19:01
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 trilom/8409e6e323916666fbdc7a56c9e67679 to your computer and use it in GitHub Desktop.
Save trilom/8409e6e323916666fbdc7a56c9e67679 to your computer and use it in GitHub Desktop.
Ohai plugin to provide semantically nice attributes for network interfaces
Ohai.plugin(:NetworkAddrs) do
provides "networkAddrs"
depends "network/interfaces", "hostname"
collect_data(:default) do
networkAddrs(Mash.new)
network[:interfaces].each do |iface, addrs|
addrs[:addresses].each do |ip, params|
networkAddrs["ipaddress_#{iface}"] = ip if params[:family].eql?('inet')
networkAddrs["ipaddress6_#{iface}"] = ip if params[:family].eql?('inet6')
networkAddrs["macaddress_#{iface}"] = ip if params[:family].eql?('lladdr')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment