pillar.get from within a pillar

113 views
Skip to first unread message

Will Platnick

unread,
Aug 14, 2013, 11:09:09 AM8/14/13
to salt-...@googlegroups.com
Are we supposed to be able to query other assigned pillar data with pillar.get from within a pillar?


{% if salt['pillar.get']('DIVISION', 'div1') == 'div2' %} is evaluating to div1, even though the DIVISION is assigned by a different pillar and is a valid working pillar on the minion?

Ethan Erchinger

unread,
Aug 14, 2013, 12:36:24 PM8/14/13
to salt-...@googlegroups.com
From what I understand, no, you cannot.  A possible options though is to set a Jinja variable if that pillar data isn't needed elsewhere, and use a Jinja include which can then see the Jinja variable.

Another option, though it requires multiple invocations, is to set a grain based on a pillar variable, and then in the next run reference the grain detail, using salt('config.get'), which will look at the minion's grains first and that variable would be set based on pillar data.  It's not as dynamic, nor is it as secure, but it does work.

Ethan

David Boucha

unread,
Aug 14, 2013, 1:00:07 PM8/14/13
to salt users list
Another option here is to create your own external pillar.

The external pillar function receives a python dict containing the regular pillar, then you can do whatever magic you want updating and modifying that dict that you then return as the final pillar.

You can actually have multiple external pillars that get executed in the order they're defined in the master config.

Here's a pretty good doc on writing an external pillar


Be sure to read the section at the very bottom regarding the available global vars.


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Dave Boucha  |  Sr. Engineer


5272 South College Drive, Suite 301 | Murray, UT 84123

office 801-305-3563
da...@saltstack.com | www.saltstack.com
Reply all
Reply to author
Forward
0 new messages