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
Written by Tom Howe
Related protips
2 Responses
Did you only distribute this on Vagrant installs, and skip it on production ones?
over 1 year ago
·
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#