I have been successfully using the grains_pcre matcher in my top file for matching grains, in my case for roles i.e.
Roles grain:
roles:
- roleA
- roleB
- roleC
Top file:
'roles:(roleA|roleB|roleC)':
- match: grain_pcre
- somepillar
I have recently extended the my roles functionality so that the structure looks like this (dictionary not list):
roles:
roleA:
None
roleB:
- envA
- envB
roleC:
- envA
Which has caused the grain_pcre matcher to behave in a very strange way - the pipe symbol (|) just doesn't work anymore. I've tried every regex trick I can think of but just can't get it to match on multiple items, this seems like a bug to me - regex should behave like regex.
Singular matches like 'roles:roleA' work fine, I can use wildcards on the sub lists 'roles:roleA:env.*' or mysteriously 'roles:roleA:env*' (no dot before the *) but I cannot get it to match using the standard pipe syntax even if I add colon characters to the relevant positions.
I've been testing using match.grain_pcre and using salt -C (compound matcher) - both seem to have the same issues, not sure if its the same code path.
I've read through a lot of documentation on the topic but most of it is based around lists not dictionaries.
There are a few workarounds I can use:
'P@roles:roleA or P@roles:roleB' (verbose, not ideal)Salt Version:
Salt: 2016.3.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: centos 6.7 Final
machine: x86_64
release: 2.6.32-573.el6.x86_64
system: Linux
version: CentOS 6.7 Final
@oliver-dungey looks like I am able to replicate this behavior as shown below:
[ch3ll@thecakeisalie salt]$ sudo salt -P 'roles:(roleA|roleB)' test.ping
No minions matched the target. No command was sent, no jid was assigned.
ERROR: No return received
[ch3ll@thecakeisalie salt]$ sudo salt -P 'roles:roleA' test.ping
thecakeisalie:
True
[ch3ll@thecakeisalie salt]$ sudo salt -P 'roles:roleB' test.ping
thecakeisalie:
True
Looks like we need to make sure we include dictionaries and not just list in a grains pcre match .Thanks for the heads up!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
@Ch3LL - this has not yet been resolved and looks pretty critical to me.. Could you please reopen the issue?
Thank you for updating this issue. It is no longer marked as stale.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
@Ch3LL still not closed...
Thank you for updating this issue. It is no longer marked as stale.
Most helpful comment
@oliver-dungey looks like I am able to replicate this behavior as shown below:
Looks like we need to make sure we include dictionaries and not just list in a grains pcre match .Thanks for the heads up!