Reputation: 564
Some of the minions have a grain like foo: bar
while others don't have that grain. What should I do to match those minions which don't have the foo
grain?
I have tried salt -G 'foo:'
and salt -P 'foo:^$'
but neither of them work.
Assume that there are 3 minions:
minion1:
----------
foo:
bar
minion2:
----------
foo:
baz
minion3:
----------
foo:
Both minion1 and minion2 have the grain foo
and minion3 is not defined this grain. How to match minion3 ONLY?
Upvotes: 0
Views: 643
Reputation: 7270
You can use -P
(Grains PCRE
):
salt -P 'foo:^(?!bar)'
Python docs for re
module says:
(?!...)
Matches if ... doesn’t match next. This is a negative lookahead assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if it’s not followed by 'Asimov'.
or just simply use a compound match with negation:
salt -C 'not G@foo:bar'
Upvotes: 1