require 'hiera_puppet' module Puppet::Parser::Functions newfunction( :hiera, :type => :rvalue, :arity => -2, :doc => < ["Edith Franklin", "Ginny Hamilton"], # regular => ["Iris Jackson", "Kelly Lambert"]} ~~~ You can optionally generate the default value with a [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) that takes one parameter. **Example**: Using `hiera` with a lambda ~~~ puppet # Assuming the same Hiera data as the previous example: $users = hiera('users') | $key | { "Key \'${key}\' not found" } # $users contains {admins => ["Edith Franklin", "Ginny Hamilton"], # regular => ["Iris Jackson", "Kelly Lambert"]} # If hiera couldn't match its key, it would return the lambda result, # "Key 'users' not found". ~~~ The returned value's data type depends on the types of the results. In the example above, Hiera matches the 'users' key and returns it as a hash. The `hiera` function is deprecated in favor of using `lookup` and will be removed in 6.0.0. See https://docs.puppet.com/puppet/#{Puppet.minor_version}/reference/deprecated_language.html. Replace the calls as follows: | from | to | | ---- | ---| | hiera($key) | lookup($key) | | hiera($key, $default) | lookup($key, { 'default_value' => $default }) | | hiera($key, $default, $level) | override level not supported | Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced result must be post processed to get exactly the same result, for example using simple hash/array `+` or with calls to stdlib's `deep_merge` function depending on kind of hiera call and setting of merge in hiera.yaml. See [the documentation](https://docs.puppetlabs.com/hiera/latest/puppet.html#hiera-lookup-functions) for more information about Hiera lookup functions. - Since 4.0.0 DOC ) do |*args| Error.is4x('hiera') end end