Debugging Hiera lookups

As you can see from the preceding example, the data that contributes to the complete configuration of any module can be rather dispersed throughout the set of your data sources. It can be challenging to determine where the respective values are retrieved from for any given agent node. It can be frustrating to trace data sources to find out why a change at some level will not take effect for some of your agents.

To help make the process more transparent, Hiera comes with a command-line tool called hiera. Invoking it is simple:

root@puppetmaster # hiera -c /etc/puppetlabs/code/hiera.yaml demo::atoms

It retrieves a given key using the specified configuration from hiera.yaml. Make sure that you use the same Hiera configuration as Puppet.

Of course, this can only work sensibly if Hiera selects the same data sources as the compiler, which uses fact values to form a concrete hierarchy. These required facts can be given right on the command line as the final parameters:

root@puppetmaster # hiera -c /etc/puppetlabs/code/hiera.yaml demo::atoms ::clientcert=int01-web01.example.net ::role=webserver ::location=ny

This prints the demo::atoms value of the specified server to the console.

Tip

The fact values can also be retrieved from a YAML file or other alternative sources. Use hiera --help to get information about the available scenarios.

Make sure that you add the -d (or --debug) flag in order to get helpful information about the traversal of the hierarchy:

root@puppetmaster # hiera -d -c ...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.70.60