Git Product home page Git Product logo

puppetlabs-nodesearch's Introduction

LICENSE: Apache v2

AUTHOR: Dan Bode

This is currently a prototype.

Overview:

This module provides facilities for searching for a list of nodes using
facts and classes contained in the last compiled catalag as filters.

Pre-requisites:

This code will only work against Puppet 2.7.3 or higher.

It requires that storedconfigs is enabled. For more information about
configuring storedconfigs, look here:

  http://projects.puppetlabs.com/projects/1/wiki/Using_Stored_Configuration


This has only been tested against mysql as the backend for storedconfigs.

Usage:

command line:

To use puppet hostclass from the command line, you will have to
add the lib directory of this module to your RUBYLIB env variabe.

  export RUBYLIB=/etc/puppet/modules/puppetlabs-nodesearch/lib:$RUBYLIB

  # returns a list of nodes whose last compiled catalog contains
  # the classes foo, bar, AND baz
  puppet hostclass search --classes foo,bar,baz

As a puppet function:

from within Puppet, you can invoke the function search_nodes

search nodes allows you to specify both facts as well as classes to
use as a filter for searching nodes.

If you intend to use facts as filters, then you will need to set inventory_active_record
as the facts terminus in puppet.conf (as as an option to puppet).

  facts_terminus=inventory_active_record

The functions search_nodes takes a hash as the only parameter.

The hash can have either keys prefixed with facts. or a key called classes which
expects an array.

Examples of usage:

The following example shows how the function could be used to grant access to a database
to only nodes that have been assigned a specific class.

node db::server {
  class { 'db::server':
    # authorize clients that use the class db::client
    allowed_clients => search_nodes({classes => ['db::client']}),
  }
}

Full examples have been provided in the examples directory:

Below is the main section from puppet.conf that I used for testing:

[main]
    storeconfigs = true
    dbadapter = mysql
    dbname = puppet
    dbserver = localhost
    dbuser = root
    dbpassword = password
    dbsocket = /var/lib/mysql/mysql.sock
    facts_terminus=inventory_active_record
    modulepath=/etc/puppet/modules:/etc/puppet/modules/puppetlabs-nodesearch/examples/modules
    manifest=/etc/puppet/modules/puppetlabs-nodesearch/examples/manifests/site.pp

puppetlabs-nodesearch's People

Contributors

nukemberg avatar hunner avatar

Watchers

James Cloos 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.