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

Geoff Williams



3,735 latest version

4.1 quality score

Version information

  • 1.2.2 (latest)
  • 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 Oct 24th 2018

Start using this module


geoffwilliams/safe_roles — version 1.2.2 Oct 24th 2018


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


Just a very simple module to convert:


  • A role fact role into a safe_role
  • A trusted fact role pp_role into safe_pp_role

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


  • 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:

  - "node/%{clientcert}".yaml
  - "%{safe_role}".yaml
  - "app_tier/%{app_tier}".yaml
  - "datacenter/%{datacenter}".yaml
  - "env/%{environment}".yaml
  - "os/%{}_%{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


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


  • Requires openssl in the PATH


  • Feel free to PR