hiera.yaml v5 and calling_module pseudo variable

84 views
Skip to first unread message

Reinhard Vicinus

unread,
Apr 10, 2017, 10:42:42 AM4/10/17
to Puppet Users
Hi,

I'm evaluating migrating from hiera.yaml v3 to hiera.yaml v5 and a problem I found is that we use the calling_module pseudo variable and I don't see any equivalent solution. The lowest level of our hierarchy looks like this:

- modules/%{calling_module}
- global

We use the pseudo variable to set up a basic configuration for every module we use when we need other default values then the ones set by the module author. In the past we had the configuration in the global.yaml at the lowest level but as we use a lot of different modules the global.yaml got obfuscated and we separated the configuration into different files via the calling_module pseudo variable.

The documentation says that the hiera module layer should be used instead of the pseudo variable calling_module. But the module layer of hiera is configured by the module author and we want to use external modules without modifying them so using the module layer is no option for us.

So did I overlook something and there is a way to keep the module configuration in separate files or do we have to return to merge all our module configuration back into the global.yaml if we want to use v5 hiera.yaml format and don't want to modify external modules?

Thanks in advance
Reinhard Vicinus

Nick Fagerlund

unread,
Apr 28, 2017, 7:12:38 PM4/28/17
to Puppet Users
Hey Reinhard,


On Monday, April 10, 2017 at 7:42:42 AM UTC-7, Reinhard Vicinus wrote:
We use the pseudo variable to set up a basic configuration for every module we use when we need other default values then the ones set by the module author. In the past we had the configuration in the global.yaml at the lowest level but as we use a lot of different modules the global.yaml got obfuscated and we separated the configuration into different files via the calling_module pseudo variable.

OK, just to make sure I understand you: The data in modules/%{calling_module} IS just global data, right? As in:

* Files like modules/apache.yaml don't override any keys from the global.yaml file.
* Files like modules/apache.yaml and modules/ntp.yaml don't set any of the same keys; their responsibilities are fully separated.
* You just want to use separate files to reduce clutter. All you want is to not have a 3000 line yaml doc.

If so, use the `glob(s)` setting for a hierarchy level. Like this!

hierarchy:
  - name: "Normal global data"
    path: global.yaml
  - name: "Overrides for module defaults"
    glob: "modules/*.yaml"


That should work with your existing data. It will load all the yaml files from your modules/ directory, and as long as they don't overlap it'll treat them as one big data file without forcing you to maintain a 3000 line yaml doc. (If they DO overlap, the first file in alphabetical order will win for a given key.)
 

Nick Fagerlund

unread,
Apr 28, 2017, 7:14:26 PM4/28/17
to Puppet Users


On Friday, April 28, 2017 at 4:12:38 PM UTC-7, Nick Fagerlund wrote:

If so, use the `glob(s)` setting for a hierarchy level. Like this!


Whoops, forgot to paste my docs link. More about `glob` and `globs` here:

https://docs.puppet.com/puppet/latest/hiera_config_yaml_5.html#specifying-file-paths
Reply all
Reply to author
Forward
0 new messages