-
-
Save trilom/8409e6e323916666fbdc7a56c9e67679 to your computer and use it in GitHub Desktop.
Ohai plugin to provide semantically nice attributes for network interfaces
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
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