Question

I'm trying to write a state file that matches on a pillar value, but I'm not sure how to (or if it's possible to) match on values of pillar attributes in dicts. The salt.module.match API docs don't go into any detail about that, and none of the obvious approaches are fruitful:

root@ms-tapir:~ # salt clowder saltutil.refresh_pillar
clowder:
    None
root@ms-tapir:~ # salt clowder pillar.item wsgi_still
clowder:
    ----------
    wsgi_still:
        ----------
        foo:
            bar
        nginx_default:
            ----------
            directives:
                - return 444
root@ms-tapir:~ # salt clowder match.pillar 'wsgi_still["foo"]:bar'
clowder:
    False
root@ms-tapir:~ # salt clowder match.pillar "wsgi_still['foo']:bar"
clowder:
    False
root@ms-tapir:~ # salt clowder match.pillar "wsgi_still.foo:bar"
clowder:
    False

My attempts to debug the situation got as far as sticking a pdb_trace() in match.py and running salt-minion in the foreground, but that was completely useless, resulting in communication errors instead of a debug shell, presumably due to Salt's weird interaction with ØMQ. :)

To clarify, the goal would be to have something like this work in my /srv/salt/top.sls file:

base:
  'wsgi_still["foo"]:bar':
    - match: pillar
    - wsgi_distiller

I have confirmed that salt clowder match.pillar "foo:bar" works for my setup (returns True), when foo: bar in this minion's pillar.

Also, I believe this is the same problem from a different angle:

root@ms-tapir:~ # salt -I "foo:bar" test.ping
clowder:
    True
root@ms-tapir:~ # salt -I "wsgi_still['foo']:bar" test.ping

I'm just including it because 'use the -I' flag is the only suggestion I've received so far. :)

Was it helpful?

Solution

Nested dicts in pillar data are accessed in the following way:

salt -I "wsgi_still:foo:bar" test.ping

The same goes for matching in the topfile:

base:
  'wsgi_still:foo:bar':
    - match: pillar
    - wsgi_distiller
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top