Each environment can have its own hiera.yaml
configuration and associated data directory. When we configured Hiera in the previous section, we placed the configuration file in /etc/puppetlabs/puppet/hiera.yaml
. This is known as the global configuration file for Hiera. Any values you set at this level will override any values we set at the environment level.
Using environment-specific Hiera, we can have different Hiera data values in the production environment than in the devel environment.
Create a hiera.yaml
file in /etc/puppetlabs/code/environments/production
with the following contents:
--- version: 5 defaults: hierarchy: - name: "Network specific data (yaml version)" path: "network/%{::facts.network}.yaml" - name: "Common" path: "common.yaml"
Next, create the data
directory to contain the environment-specific data:
[root@puppet ~]# mkdir /etc/puppetlabs/code/environments/production/data