Skip to content

Instantly share code, notes, and snippets.

@reset
Created July 12, 2011 21:11
Show Gist options
  • Save reset/1078990 to your computer and use it in GitHub Desktop.
Save reset/1078990 to your computer and use it in GitHub Desktop.
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