saltstack / saltstack/salt

file.recurse: exclude_pat not working when providing a list of glob patterns

Open
#54,399 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed help-wanted severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Salt file.recurse entry point and trace how exclude_pat is processed when given glob patterns. Reproduce the a*|b* example and compare it with the working regular-expression example. Done means a list of glob patterns excludes matching files such as ab and ba, with regression coverage for the reported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.