Hiera calling conventions for backend functions

Hiera uses the following conventions when calling backend functions.

Hiera calls data_hash one time per data source, calls lookup_key functions one time per data source for every unique key lookup, and calls data_dig functions one time per data source for every unique sequence of key segments.

However, a given hierarchy level can refer to multiple data sources with the path, paths, uri, uris, glob, and globs settings. Hiera handles each hierarchy level as follows:

  • If the path, paths, glob, or globs settings are used, Hiera determines which files exist and calls the function one time for each. If no files were found, the function is not be called.
  • If the uri or uris settings are used, Hiera calls the function one time per URI.
  • If none of those settings are used, Hiera calls the function one time.

Hiera can call a function again for a given data source, if the inputs change. For example, if hiera.yaml interpolates a local variable in a file path, Hiera calls the function again for scopes where that variable has a different value. This has a significant performance impact, so you must interpolate only facts, trusted facts, and server facts in the hierarchy.