Skip to content

Instantly share code, notes, and snippets.

@bbrowning
Created February 17, 2010 16:42
Show Gist options
  • Save bbrowning/306788 to your computer and use it in GitHub Desktop.
Save bbrowning/306788 to your computer and use it in GitHub Desktop.
class Chef
class Recipe
# Shortcut for getting a hash of internal hosts and their ips
def internal_hosts
hosts = {}
search(:node, "*") do |server|
# on rackspace eth1 is internal
server_ips = server["network"]["interfaces"]["eth1"]["addresses"]
internal_ip = server["ipaddress"]
server_ips.each_pair do |addr_key, addr_value|
if addr_value == "inet"
internal_ip = addr_key.sub(/_family/, '')
break
end
end
hosts[server["fqdn"]] = internal_ip
end
hosts
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment