Skip to content

Instantly share code, notes, and snippets.

@binamov
Created April 25, 2014 17:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save binamov/11297440 to your computer and use it in GitHub Desktop.
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/
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