Forge Home

safe_roles

refomat any `role` or `pp_role` fact into a filesystem path

11,516 downloads

270 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

  • 1.3.1 (latest)
  • 1.3.0
  • 1.2.3
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • 1.1.0
  • 1.0.2
  • 1.0.1
  • 1.0.0
  • 0.2.0
  • 0.1.0
released Apr 16th 2023

Start using this module

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

Add this module to your Puppetfile:

mod 'geoffwilliams-safe_roles', '1.3.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add geoffwilliams-safe_roles
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install geoffwilliams-safe_roles --version 1.3.1

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

geoffwilliams/safe_roles — version 1.3.1 Apr 16th 2023

safe_roles

Table of Contents

  1. Description
  2. Setup - The basics of getting started with safe_roles
  3. Usage - Configuration options and additional functionality
  4. Limitations - OS compatibility, etc.
  5. Development - Guide for contributing to the module

Description

Just a very simple module to convert:

roles

  • A role fact role into a safe_role

  • A trusted fact role pp_role into safe_pp_role

    Warning: safe_pp_role is NOT a trusted fact and can be overwritten by the agent!

The conversion process is to convert double colons (::) into slashes (/).

os

  • A normalised safe_os fact:
    • All values lowercased (eg: RedHat -> redhat)
    • All spaces removed from values (eg 2012 R2 -> 2012_r2)

This lets us write hiera.yaml files that look like this:

:hierarchy:
  - "node/%{clientcert}".yaml
  - "%{safe_role}".yaml
  - "app_tier/%{app_tier}".yaml
  - "datacenter/%{datacenter}".yaml
  - "env/%{environment}".yaml
  - "os/%{facts.safe_os.family}_%{facts.safe_os.release.major}.yaml"
  - common.yaml

This means that:

  • A node that has a role or pp_role value of foo::bar::baz will attempt to read hiera data from role/foo/bar/baz.yaml (instead of role/foo::bar::baz.yaml)
  • A windows 2012 R2 node would attempt to read from os/windows_2012_r2.yaml (instead of os/windows_2012 R2.yaml)
  • A RHEL 7 node would attempt to read read from os/redhat_7.yaml (instead of os/RedHat_7.yaml)

This resolves the problems that:

  • :: in filenames only works on linux
  • Windows and MacOS have case insensitive filesystems which can result in broken git repositories when files are checked in accidentally that differ only by case
  • Filenames need spaces when dealing with some Windows variants

Setup

Just install the module and the facts will be created if applicable

Limitations

  • Requires openssl in the PATH

Development

  • Feel free to PR