Dear Community,
I've recently discovered that the `hiera()` lookup function behaves differently for non-existent keys when used in a YAML interpolation token vs. when called directly. In the latter case, the following statements (correctly) raise an error:
CLI:
$ puppet apply -e "notice(hiera('non-existent'))"
Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item non-existent in any Hiera data file and no default supplied...
site.pp:
class configuration {
hiera('non-existent')
}
=> Same Error message
However, if I lookup a non-existent key in a YAML interpolation token, **no error** is being reported and the function seems to return the empty string:
YAML
---
limbo: "%{hiera('non-existent)}"
I spent several hours debugging a puppet module, which failed due to a parameter set to the empty string. This unexpected behaviour was caused by the hiera() lookup function silently ignoring a key that wasn't initialised. Is this really intended behaviour? Or am I using the lookup function incorrectly? Have I missed something in the documentation?
Thank you for your help clarifying this issue
↧