Setting node-specific data with Hiera
In our hierarchy defined in hiera.yaml
, we created an entry based on the hostname fact; in this section, we'll create yaml
files in the hosts
subdirectory of Hiera data with information specific to a particular host.
Getting ready
Install and configure Hiera as in the last section, and modify the hierarchy defined in the previous recipe to include a hosts/%{hostname}
entry, as follows:
--- # Hiera 5 Global configuration file version: 5 hierarchy: - name: "Per-host defaults" path: "hosts/%{::facts.hostname}.yaml" - name: "Per-OS defaults" path: "os/%{::facts.os.family}.yaml" - name: "Common data" path: "common.yaml"
How to do it...
Create a file at
/etc/puppetlabs/puppet/data/hosts
that is the hostname of yourtest
node. For example, if your host is namedtestnode
, the file would be namedtestnode.yaml
.- Insert a specific message in this file:
message: 'This is the test node for the cookbook'
- Run Puppet on two different test nodes to note the...