One of the best features of Hiera in Puppet 5 is that it is included by default, and does not require an additional installation. As noted in the previous chapter, Puppet 5 gives us three levels of Hiera: global, environment, and data, in modules. The environment level of Hiera is contained in the control repository, giving us separate data in each environment and allowing us to store all of our Hiera data in a single repository.
This model allows us to version control all of our data layer in Puppet 5 easily, and even merge our data across branches, if we want to iterate development of our Hiera data in the same way that we iterate over the development of Puppet code. We can use the same Hiera v5 configuration from the Chapter 4, Hiera 5, shown as follows, to set up our data in environments:
---
version: 5
hierarchy:
- name: "Per-node data"
path: "nodes/%{trusted.certname}.yaml"
- name: "Per-environment data"
path: " %{server_facts.environment}.yaml"
- name: Common
path: common.yaml
This will use the default datadir in the control-repo, data, to store our Hiera data. If we were to use this hierarchy, our control repository might contain the following:
├── data
│ ├── common.yaml
│ ├── development.yaml
│ ├── nodes
│ │ ├── server1.ourcompany.net.yaml
│ │ └── server2.ourcompany.net.yaml
│ ├── preprod.yaml
│ ├── production.yaml
│ └── staging.yaml
└── hiera.yaml