Discovery cookbook for search, implements Discovery#search environment and non-environment aware search for roles with a few extra checks
Switch branches/tags
Nothing to show
Pull request Compare This branch is 23 commits behind hw-cookbooks:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Discovery Library


You can use the #search method to locate a role, optionally restricted to the environment.

It will fall back to searching the local nodes run_list for roles, so you can have less logic flow in recipes.

host ="any_role",
                        :node => node,
                        :environment_aware => false)


You can use the #all method to locate all nodes with a role, optionally restricted to the environment.

Additional options:

hosts = Discovery.all("base",
                      :node => node,
                      :environment_aware => true,
                      :empty_ok => false,
                      :remove_self => true,
                      :minimum_response_time => false)


You can use the #ipaddress method to automatically grab a prioritised ipaddress from a node.

The remote node will be compared against the same node, if any are in any clouds detected by ohai (and they are in the same cloud) the local ipv4 will be returned.

You can optionally supply a type argument specifying which ipaddress you would like.

ipaddress = Discovery.ipaddress(:remote_node => host,
                                :node => node)
local_ipv4 = Discovery.ipaddress(:remote_node => host,
                                 :node => node,
                                 :type => :local)
public_ipv4 = Discovery.ipaddress(:remote_node => host,
                                 :node => node,
                                 :type => :public)

Recipe DSL

Recipe DSL versions of the search, all and ipaddress methods are avaialble for the class; using them means you do not need to explicitly pass the node:

  • discovery_search
# Note omission of :node => node 
host = discovery_search("base",
                        :environment_aware => true,
                        :empty_ok => false,
                        :remove_self => true,
                        :minimum_response_time => false)
  • discovery_all
hosts = discovery_all(...)
  • discovery_ipaddress
host = discovery_search(...)
ipaddress = discovery_ipaddress(:remote_node = host)