-
-
Save schisamo/1055220 to your computer and use it in GitHub Desktop.
You could put the ohai plugin file in /cookbooks/ohai/files/default/plugins and the ohai cookbook will distribute it for you.
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
provides "gamespy" | |
require_plugin "kernel" | |
require_plugin "network" | |
def get_ip_address(name, eth) | |
network[:interfaces][eth][:addresses].each do |key, info| | |
gamespy[name] = key if info['family'] == 'inet' | |
end | |
end | |
def has_dsr_interfaces? | |
return network[:interfaces].has_key?('eth0') && | |
network[:interfaces].has_key?('eth1') && | |
network[:interfaces].has_key?('lo:0') | |
end | |
def looks_like_matchmaking? | |
has_dsr_interfaces? | |
end | |
if looks_like_matchmaking? | |
gamespy Mash.new | |
get_ip_address(:private_ipv4, :eth0) | |
get_ip_address(:public_ipv4, :eth1) | |
get_ip_address(:loopback, "lo:0".to_sym) | |
end |
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
# this code is not needed if use the ohai cookbook to distribute plugin | |
# force template creation and ohai reload in compile phase so | |
# the attribute data returned by the plugin data is available for | |
# recipes during execute phase | |
template "#{node[:ohai][:plugin_path]}/gamespy.rb" do | |
source "gamespy.ohai.erb" | |
owner "root" | |
group "root" | |
mode 0755 | |
action :nothing | |
end.run_action(:create) | |
ohai 'gamespy' do | |
action :nothing | |
end.run_action(:reload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment