Using pillar data in an external PillarStack

Posted by: on

Problem

You are using the PillarStack external pillar in salt and need to reference a value defined in the standard pillar data, but salt['pillar.get'] does not work at all (salt is not defined in the PillarStack context) and __salt__['pilar.get']—although defined—returns none (or the default value specified).

Solution

The stack pilar provides generalised recursive access to dictionaries through the __stack__['traverse'] function.

So, instead of:

1
{{ salt['pillar.get']('some:nested:pillar', 'default') }}

Simply use:

1
{{ __stack__['traverse'](pillar, 'some:nested:pillar', 'default') }}

Discussion

See Github issue #13 and associated thread for details.

Basically, the native pillar.get does not work in the context of the PillarStack system so the author provided and generalised workaround to traverse any available dictionary from Jinja in your PillarStack data.