Skip to content

Instantly share code, notes, and snippets.

@rcreasey
Created June 29, 2011 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rcreasey/1054954 to your computer and use it in GitHub Desktop.
Save rcreasey/1054954 to your computer and use it in GitHub Desktop.
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
template "#{node[:ohai][:plugin_path]}/gamespy.rb" do
source "gamespy.ohai.erb"
owner "root"
group "root"
mode 0755
notifies :restart, 'ohai[gamespy]'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment