Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Experiment for querying data out of storedconfigs

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.