Created
February 17, 2010 16:42
-
-
Save bbrowning/306788 to your computer and use it in GitHub Desktop.
This file contains 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
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