On 24/05/17 18:41, Martin Alfke wrote:
> Hi Rudy,
>
> I don’t know whether someone already replied.
>
https://docs.puppet.com/puppet/4.10/hiera_migrate_v3_yaml.html#remove-hierarchy-levels-with-callingmodule-and-friends
>
> Quote from the link:
>
> Remove hierarchy levels with calling_module and friends
>
> Hiera 3 could use three special pseudo-variables (which weren’t available in Puppet code) in its hierarchy:
>
> • calling_module
> • calling_class
> • calling_class_path
> Hiera.yaml version 5 doesn’t support these, so you must drop any hierarchy levels that interpolate them.
>
> These variables were added to support a hacky predecessor of module data; anything you were doing with them is better accomplished with the module layer.
>
> Martin
>
It is worth pointing out that using calling_module/class etc. is
typically used to keep the data for a module/class (etc) in a separate
file/directory and then interpolate to get it. Most users do not use
these features for (the bad, anti-pattern) of binding the same key to
different values depending on from where it is looked up (that is the
main reason those keys are no longer supported, but it is also performance).
So - if not relying on the anti-pattern (which you should not), then all
the values in all the referenced files can actually be bound at the same
time and there is not need to differentiate on them using paths.
If there is a desire to keep data separate, they can be stored in
separate files and the `glob` variant can be used to read all of them.
Say you want to be able to override different classes at the environment
level - you could then create a directory called 'classes', and for each
class you would have a data file in that directory. Each data file by
convention would then only contain keys for that class. You then map all
of them with a glob in your hiera.yaml.
If the purpose was to provide defaults, simply place a hiera.yaml in
your module and keep the (default) data for the module there.
Hope that helps.
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/