Giter Club home page Giter Club logo

chef-solo-search's Introduction

chef-solo-search

Chef-solo-search is a cookbook library to add data bags and search powers to chef-solo. Thanks for the initial idea and code goes to Brian Akins http://lists.opscode.com/sympa/arc/chef/2011-02/msg00000.html Please see Supported queries for a list of query types which are supported.

Requirements

* ruby >= 1.8
* ruby-chef >= 0.10

Installation

In order to use this extension, create a (dummy-) cookbook and add a directory called libraries. Next copy libraries/search.rb and libraries/data_bags.rb to the newly created directory. Now you have to make sure chef-solo knows about data bags, therefor add

data_bag_path "<node_work_path>/data_bags"

to the config file of chef-solo (defaults to /etc/chef/solo.rb).

Supported queries

The search methods supportes a basic sub-set of the lucene query language. Sample supported queries are:

General queries:

search(:users, "*:*")
search(:users)
search(:users, nil)
    getting all items in ':users'
search(:users, "username:*")
search(:users, "username:[* TO *]")
    getting all items from ':users' which have a 'username' attribute
search(:users, "(NOT username:*)")
search(:users, "(NOT username:[* TO *])")
    getting all items from ':users' which don't have a 'username' attribute

Queries on attributes with string values:

search(:users, "username:speedy")
    getting all items from ':users' with username equals 'speedy'
search(:users, "NOT username:speedy")
    getting all items from ':users' with username is unequal to 'speedy'
search(:users, "username:spe*")
    getting all items which 'username'-value begins with 'spe'

Queries on attributes with array values:

search(:users, "children:tom")
    getting all items which 'children' attribute contains 'tom'
search(:users, "children:t*")
    getting all items which have at least one element in 'children'
    which starts with 't'

Queries on attributes with boolean values:

search(:users, "married:true")

Queries in attributes with integer values:

search(:users, "age:35")

OR conditions in queries:

search(:users, "age:42 OR age:22")

AND conditions in queries:

search(:users, "married:true AND age:35")

NOT condition in queries:

search(:users, "children:tom NOT gender:female")

More complex queries:

search(:users, "children:tom NOT gender:female AND age:42")

special case: 'chef_environment:_default'

Searching within the '_default' environment is also supported

search(:users, "age:35 AND chef_environment:_default")

Running tests

Running tests is as simple as:

% ruby -Ilibraries tests/test_search.rb -v

chef-solo-search's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.