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 use the hierarchy defined in the previous recipe that includes a hosts/%{hostname}
entry.
How to do it...
The following are the steps:
Create a file at
/etc/puppet/hieradata/hosts
that is the hostname of your test node. For example if your host is namedcookbook-test
, then the file would be namedcookbook-test.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 difference:
t@ckbk:~$ sudo puppet agent -t Info: Caching catalog for cookbook-test Notice: Message is This is the test node for the cookbook [root@hiera-test ~]# puppet agent -t Info: Caching catalog for hiera-test.example.com...