salt icon indicating copy to clipboard operation
salt copied to clipboard

RFE: Hierarchical substitution in Pillars

Open ake-persson opened this issue 13 years ago • 4 comments

Hi

For Puppet we used Hierarchical substitution similar to Hiera, which mapped very nicely to location based information. It would be a nice feature in Pillar if you could have this with Jinja templating.

Example:

Region -> Country -> Datacenter -> Host

region/
    emea.sls
    amer.sls
country/
    us.sls
    nl.sls
datacenter/
    qube.sls
    circle.sls
host/
    foobar.sls

Best Regards Michael

ake-persson avatar Aug 21 '13 07:08 ake-persson

This would be great. Particularly if you can define any arbitrary hierarchy, with order based on order in the file (i.e. region is applied first, then country may add additional parameters applied to a state, or override region, likewise for datacenter, etc., and I may want to define something completely orthogonal like 'owner' or 'security class'.

smithjm avatar Aug 21 '13 12:08 smithjm

This would be cool. Thanks for the request.

basepi avatar Aug 21 '13 22:08 basepi

Be careful here.. you think you only need something simple, but quickly you discover you need more complex combinations of keys (which will only increase in number), evaluated in a specific order, where the order may vary by another key or combination of keys. I suspect that it'd be a good idea to provide an example external pillar script/plugin that's useful for a few cases, but not integrate it tightly into the system.

rmt avatar Oct 02 '13 15:10 rmt

I made a simple parser for Hierarchical Substitution and using Jinja2, that could be used for creating static Grains or as a Pillar plugin.

https://github.com/mickep76/pepa

ake-persson avatar Oct 09 '13 13:10 ake-persson