hwiohg
Last Updated: February 25, 2016
·
4.438K
· turtlebender
8c1f0451a8f198101581a98d4964c156

Ohai plugin to use eth1 on vagrant boxes

I often use vagrant multi-box setups. One issue is that if my chef recipes use the ipaddress attribute, I get the private ip address which won't allow my boxes to talk to each other.

To fix this I wrote a silly little ohai plugin:

provide "ipaddress"
require_plugin "#{os}::network"
network["interfaces"]["eth1"]["addresses"].each do |ip, params|
  if params['family'] == ('inet')
      ipaddress ip
  end
end

Include this in your ohai cookbook as described here: http://wiki.opscode.com/display/chef/Distributing+Ohai+Plugins

HtH

Say Thanks
Respond

2 Responses
Add your response

2850
6142862bb6711cc286f23c40ae0d3686

Did you only distribute this on Vagrant installs, and skip it on production ones?

over 1 year ago ·
15873
1015200

If you wrap the logic in if virtualization["system"] == "vbox" you can distribute this to your production environment without worries it'll execute.

over 1 year ago ·