# Sample Chef partial search functions.
# These chef library functions require "partial_search" cookbook.
# Upload "partial_searck" cookbook and then modify the metadata.rb file to
# make "partial_search" cookbook as dependency.
#
#
# The following two functions will return the IP of the node running grahite and the port
# to which data can be send for storage.
#
def get_graphite_vip
ret = []
results = partial_search(:node, 'recipes:bcpc\:\:graphite',
:keys => { 'vip' => [ 'bcpc', 'graphite', 'ip' ]}).each do |result|
ret << result['vip']
end
return ret.uniq[0]
end
def get_graphite_port
ret = []
results = partial_search(:node, 'recipes:bcpc\:\:graphite',
:keys => { 'port' => [ 'bcpc', 'graphite', 'port' ]}).each do |result|
ret << result['port']
end
return ret.uniq[0]
end
#
#The following returns an array of hash with the hostname and the bcpc.node_number attributes of all nodes which ran #bcpc-hadoop::zookeeper_server recipe
#
def get_host_attributes()
srch_keys = {
'hostname' => [ 'hostname' ],
'node_number' => ['bcpc','node_number']
}
results = partial_search(:node, "recipes:bcpc-hadoop\\:\\:zookeeper_server",
:keys => srch_keys)
return results
end
Last active
August 29, 2015 14:02
-
-
Save bijugs/63795bc1016bcf7e5a06 to your computer and use it in GitHub Desktop.
Partial search in Chef
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment