Working with the command line on a YAML backend

When we use a backend based on files such as JSON or YAML, which are the most commonly used, we have to recreate on the filesystem the hierarchy defined in our hiera.yaml file; the files that contain Hiera data must be placed in these directories.

Let's see Hiera in action. Provide a sample hierarchy configuration as follows:

:hierarchy:
  - "nodes/%{::fqdn}"
  - "env/%{::env}"
  - common

:yaml:
  :datadir: /etc/puppet/hieradata

We have to create a directory structure as follows:

mkdir -p /etc/puppet/hieradata/nodes
mkdir -p /etc/puppet/hieradata/env

Then, work on the YAML files as shown:

vi /etc/puppet/hieradata/nodes/web01.example42.com.yaml
vi /etc/puppet/hieradata/env/production.yaml
vi /etc/puppet/hieradata/env/test.yaml ...

Get Extending Puppet now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.