Created
July 12, 2011 21:11
-
-
Save reset/1078990 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
def find_memcached_nodes | |
find_nodes_with_role('enmasse_online_memcached', node.chef_environment) | |
end | |
def find_nodes_with_role(role, environment) | |
return [node] if node.chef_environment == 'development' | |
results = search(:node, "role:#{role} AND chef_environment:#{environment}") | |
if node.run_list.roles.include?(role) | |
results << node | |
end | |
if results.length == 0 | |
Chef::Log.error("No node with role [#{role}] in the [#{environment}] environment was found.") | |
end | |
results.uniq | |
end | |
memcached_nodes = find_memcached_nodes.collect do |mem_node| | |
memcached_listen = mem_node.enmasse_online.memcached.listen rescue node.enmasse_online.memcached.listen | |
memcached_port = mem_node.enmasse_online.memcached.port rescue node.enmasse_online.memcached.port | |
"#{memcached_listen}:#{memcached_port}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment