Created
April 25, 2014 17:40
-
-
Save binamov/11297440 to your computer and use it in GitHub Desktop.
An Ohai 7 plugin that assigns the IP address of eth1 to node.ipaddress attribute (for virtualbox vagrant boxes). It's an Ohai 7 rewrite of this: http://johntdyer.com/blog/2013/01/25/ohai/
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(:Vboxipaddress) do | |
provides "ipaddress" | |
depends "ipaddress", "network/interfaces", "virtualization/system", "etc/passwd" | |
collect_data(:default) do | |
if virtualization["system"] == "vbox" | |
if etc["passwd"].any? { |k,v| k == "vagrant"} | |
if network["interfaces"]["eth1"] | |
network["interfaces"]["eth1"]["addresses"].each do |ip, params| | |
if params['family'] == ('inet') | |
ipaddress ip | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment