Forge Home

cidr_facts

Set facts based on network ranges

10,041 downloads

9,173 latest version

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

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.1.6 (latest)
  • 0.1.5
  • 0.1.4
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Jul 14th 2017
This version is compatible with:
  • Debian, RedHat, Ubuntu, Windows, Solaris, AIX

Start using this module

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

Add this module to your Puppetfile:

mod 'dylanratcliffe-cidr_facts', '0.1.6'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add dylanratcliffe-cidr_facts
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install dylanratcliffe-cidr_facts --version 0.1.6

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.

Download

Documentation

dylanratcliffe/cidr_facts — version 0.1.6 Jul 14th 2017

CIDR Facts module

Define facts by network zone.

This module allows you to define attributes of many network zones and combine them into a single fact for each server.

It is very common for custom facts to be determined based on the network zone that a machine is in. However creating a new custom fact for each attribute that can be determined by IP address can be extremely tedious and the logic can become extremely complex, especially if your network is not straightforward. i.e. If 10.36.x.x is production, with the exception of 10.36.12.x, which is UAT

How it works

This module works by reading json files from the lib/facter/cidr.d directory. These files are added to a custom module and are distributed to each node using pluginsync. Each JSON file contains a hash of the following structure:

{
  "CIDR": {
    "some_fact": "some_value"
  }
}

The data from all .json files is merged and the facts that apply to a given node are returned. If a node is part of multiple CIDR ranges that define the same fact, the most specific (smallest) range will take precedence. Here is a real life example:

{
  "10.23.0.0/16": {
    "datacenter": "kyabram"
  },
  "10.23.18.0/24": {
    "zone": "DMZ",
    "owner": "Dylan"
  },
  "10.23.18.192/26": {
    "zone": "SUPER-DMZ",
    "compliance_level": "excruciating"
  }
}

Given the above data, a node with the IP 10.23.18.212 would have the following facts:

{
  "datacenter": "kyabram",
  "owner": "Dylan",
  "zone": "SUPER-DMZ",
  "compliance_level": "excruciating"
}