Hiera is great for the organization of the data that is used to deploy nodes. If you create a hierarchy that accurately describes your infrastructure, you can achieve great reductions in complexity. Debugging can be a pain, though. When debugging, you need to know the fact values that were used to retrieve the Hiera values. In this section, we'll work through an example of how a Hiera value can be changed, depending on the values returned by Facter.
For this example, we will configure Hiera with a custom hierarchy and then use the values from Facter on a node to perform lookups with the command-line Hiera tool:
Configure Hiera with the following hierarchy in
hiera.yaml
::hierarchy: - defaults - hosts/"%{hostname}" - environments/"%{environment}" - architecture/"%{architecture}" - "%{operatingsystem}/%{operatingsystemrelease}" - global
Create hieradata files in the
architecture
andoperatingsystem
directories with values that we can retrieve, as follows:Create a YAML file in...