Jochem
Jochem

Reputation: 51

Working with jinja and pillars.get() in saltstack // Filter works not as expected

I have different results in the bash command line and in a SLS file for pillar.get().

In the command line I receive the expected results.

salt-master:/srv/pillar # salt salt-minion2 pillar.get mqobjdetails
salt-minion2:
    ----------
    QM200@QLOCAL@LQ2:
        ----------
        DEFPSIST:
            NO
        GET:
            ENABLED
        MAXDEPTH:
            5000
        MAXMSGL:
            4194304
        MONQ:
            QMGR
    QM200@QMGR@QM200:
        ----------
        DEADQ:
        MAXMSGL:
            4194304
        MONCHL:
            OFF
        MONQ:
            OFF

and with filter

salt-master:/srv/pillar # salt salt-minion2 pillar.get mqobjdetails:QM200@QLOCAL@LQ2
salt-minion2:
    ----------
    DEFPSIST:
        NO
    GET:
        ENABLED
    MAXDEPTH:
        5000
    MAXMSGL:
        4194304
    MONQ:
        QMGR

When I try the same thing in a state file with the following jinja loop statement

{% for objkey, parameters in pillar.get('mqobjdetails', { } ).items() %}

the loop works as expected.

When I try it with the additional filter

{% for name, value in pillar.get("mqobjdetails:QM200@QMGR@LQ2", { } ).items() %}

the loop is never run through. So it seems the I get back an empty set in this case.

What do I wrong? Can somebody help me, please?

Upvotes: 2

Views: 3092

Answers (1)

Jochem
Jochem

Reputation: 51

I just found the answer in the documentation.

The pillar.get Function

There is a note, which compares pillar.get() vs salt'pillar.get'.

Well, when I use something like

{% for name, value in salt['pillar.get']('mqobjdetails:' ~ foo, { } ).items() %}

I get the expected results.

Still I do not like the idea, that the same function has different behaviours.

Upvotes: 3

Related Questions