lookup_key backends
A lookup_key backend function looks up a single key and returns its value. For
example, the built-in hiera_eyaml backend is a
lookup_key function.
You can view its source on Git at eyaml_lookup_key.rb.
On this page:
Arguments
Hiera calls a lookup_key function with
three arguments:
A key to look up.
A hash of options.
A
Puppet::LookupContextobject.
Return type
The function must either call the context object’s not_found method, or
return a value for the requested key. It can return undef as a value.
Puppet language example signature:
function mymodule::hiera_backend(
Variant[String, Numeric] $key,
Hash $options,
Puppet::LookupContext $context,
)
Ruby example signature:
dispatch :hiera_backend do
param 'Variant[String, Numeric]', :key
param 'Hash', :options
param 'Puppet::LookupContext', :context
end
A lookup_key function can return a hash for the the
lookup_options key to configure merge behavior for other keys. See
Configuring merge behavior in Hiera data for more
information. To support Hiera interpolation tokens, for
example, %{variable} or %{lookup('key')} in your data,
call context.interpolate on your values before returning them.
Related information