Debugging Hiera
When debugging Hiera, puppet lookup
can help identify exactly what Hiera was doing when it raised
an error, or how it decided to look up a key and where it got its value.
Use these examples to guide you in debugging Hiera with
the puppet lookup
command.
Syntax errors
Consider the following error message.
SERVER: Evaluation Error: Error while evaluating a Resource Statement, Lookup of key 'pe_console_prune::ensure_prune_cron' failed: DataBinding 'hiera': (<unknown>): mapping values are not allowed here at line 2 column 68 on node master.inf.puppetlabs.demo
In this example, the last thing Hiera was doing when it
threw the error was looking for the common
datasource in the YAML backend.
That is, it was reading common.yaml
. Therefore, the syntax error must be in
common.yaml
.
Unexpected values
Sometimes Hiera does not throw an error, but still fails to return the value you expect.
For example, if you think your node is configured to use au.pool.ntp.org
but it is actually configured with us.pool.ntp.org
, there is no error
message but something is wrong.
The lookup
command accepts a --node
flag to set the node
context for performing the lookup. If --node
isn’t passed, the default is
the context of the node on which the command runs.
Common errors
In addition to knowing how to use the puppet lookup
command, knowing some common errors can be useful in debugging Hiera.