Coder Social home page Coder Social logo

ninefold / discovery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hw-cookbooks/discovery

0.0 8.0 0.0 115 KB

Discovery cookbook for search, implements Discovery#search environment and non-environment aware search for roles with a few extra checks

Home Page: ckbk.it/discovery

Ruby 100.00%

discovery's Introduction

Discovery Library

Search

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 = Discovery.search("any_role",
                        :node => node,
                        :environment_aware => false)

All

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)

ipaddress

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)

Raw attribute search

Perform raw attribute searching instead of just restricting search to role names:

host = Discovery.search("attr_name:attr_value",
                        :node => node,
                        :environment_aware => false,
                        :raw_search => true)

discovery's People

Contributors

chrisroberts avatar alanshields avatar danryan avatar webframp avatar

Watchers

Andrew Harvey avatar Julian avatar James Cloos avatar Stephen Hickie avatar Warren Bain avatar  avatar  avatar Shaun Domingo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.