file.recurse: exclude_pat not working when providing a list of glob patterns
Description of Issue
exclude_pat not working when providing a list of glob patterns For the below state:
copyfiles:
file.recurse:
- name: /opt/path/
- source: salt://temp
- template: jinja
- keep_source: False
- exclude_pat: a*|b*
It will execute:
<UUID>:
----------
ID: copyfiles
Function: file.recurse
Name: /opt/path/
Result: True
Comment: Recursively updated /opt/path/
Started: 02:38:29.137763
Duration: 1432.135 ms
Changes:
----------
/opt/path/ab:
----------
diff:
New file
mode:
0644
/opt/path/ba:
----------
diff:
New file
mode:
0644
Summary for <UUID>
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 1.432 s
both ab and ba are copied, but according to the documentation:
https://docs.saltstack.com/en/develop/ref/states/all/salt.states.file.html
exclude_pat
Exclude this pattern, or list of patterns, from the source when copying.
But changing to a list of regexp will make it work:
copyfiles:
file.recurse:
- name: /opt/path/
- source: salt://temp
- template: jinja
- keep_source: False
- exclude_pat: E@(a[a-zA-Z])|(b[a-zA-Z])
result in:
<UUID>:
----------
ID: copyfiles
Function: file.recurse
Name: /opt/path/
Result: True
Comment: The directory /opt/path/ is in the correct state
Started: 02:42:29.725374
Duration: 392.615 ms
Changes:
Summary for <UUID>
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 392.615 ms
Setup
See above
Steps to Reproduce Issue
See above
Versions Report
Salt-master:
Salt Version:
Salt: 2018.3.0
Dependency Versions:
cffi: 1.12.3
cherrypy: unknown
dateutil: 2.5.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.10.1
libgit2: 0.24.5
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.24.2
Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
python-gnupg: Not Installed
PyYAML: 5.1.2
PyZMQ: 18.1.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.3.2
System Versions:
dist: debian 9.3
locale: ANSI_X3.4-1968
machine: x86_64
release: 4.14.127+
system: Linux
version: debian 9.3
Minion:
Salt Version:
Salt: 2018.3.0
Dependency Versions:
cffi: 1.11.2
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: 3.7.2
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.10
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.4
mysql-python: Not Installed
pycparser: 2.17
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.5 (default, Apr 05 2018, 13:30:06) [GCC]
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 17.0.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.2.3
System Versions:
dist:
locale: UTF-8
machine: x86_64
release: 4.12.14-150.14-default
system: Linux
version: Not Installed
Thanks for submitting @emasean I don't have the most experience with regex on this, but if you run this state first (assuming you remove the newly created files beforehand):
copyfiles:
file.recurse:
- name: /opt/path/
- source: salt://temp
- template: jinja
- keep_source: False
- exclude_pat: E@(a[a-zA-Z])|(b[a-zA-Z])
do you still get the same result from using exclude_pat: a*|b* ?
No, I cleanup the target folder first from the files ab and ba, then run the state with regexp instead and nothing was copied (the exclusion rule works for a list of regexp but not for a list of glob pattern).
Okay cool, just wanted to verify! Thanks!
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.
Thank you for updating this issue. It is no longer marked as stale.
Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.
Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.
If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.