Forge Home


Functions for finding nodes with matching resources


1,023 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.1.0 (latest)
released Sep 17th 2021
This version is compatible with:
  • Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x
  • Puppet >= 6.21.0 < 8.0.0
  • CentOS, OracleLinux, RedHat, Scientific, Debian, Ubuntu, Fedora, Darwin, SLES, Solaris, windows, AIX

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'southalc-peers', '0.1.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add southalc-peers
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install southalc-peers --version 0.1.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



southalc/peers — version 0.1.0 Sep 17th 2021


Table of Contents

  1. Description
  2. Setup
  3. Usage
  4. Limitations
  5. Development


This module includes functions to obtain an array of nodes with puppet resources that match specific criteria. This is useful for things like getting a dynamic list of nodes that are cluster members. The module does not use exported resources, although puppetdb is required.


Deploying the module to an environment should be all that is necessary to use the included functions. The module does not manage any resources.


The following example uses the 'peers::resource_by_param' function in a manifest to get an array of nodes that have the 'elasticsearch' class assigned with the '' parameter set to 'cluster-1'. Based on the returned array you can do things like check if the current node is already a member, join the cluster, adjust the value for quorum, and update seed hosts.

$elk_servers = peers::resource_by_param('elasticsearch', '', 'cluster-1')

The functions default to the node's environment, but this can be overridden by passing another parameter to the function. To repeat the last Elasticsearch query, but in the "test" environment:

$elk_servers = peers::resource_by_param('elasticsearch', '', 'cluster-1', 'test')

The other module functions enable searching for nodes based on different criteria. See the module reference for details, but here's another example to get nodes with the 'elasticsearch' module assigned, this time matching nodes based on the trusted fact extension 'pp_cluster' set to the value of 'cluster-01':

$elk_servers = peers::resource_by_tx('elasticsearch', 'pp_cluster', 'cluster-01')

Besides direct configuration of the Elasticsearch cluster, the array of cluster nodes could be useful to setup a kibana resource:

$elk_servers = peers::resource_by_param('elasticsearch', '', 'cluster-1')

class { 'kibana':
  config  => {
    ''         => fact('networking.ip'),
    'elasticsearch.hosts' => $ |$node| { "http://${node}:9200" },


The module uses a fairly basic puppetdb query and should work with all supported Puppet distributions where puppetdb is included.


I'd appreciate any feedback. To contribute to development, fork the source and submit a pull request.