saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:

Home Page:https://repo.saltproject.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] file.recurse clean on windows removing files from master.

whytewolf opened this issue · comments

Description
When using file directory structure with forward slashes instead of backslashes file.recurse clean will delete files after putting them on the minion.

Setup

mkdir /srv/salt/tests/files
touch /srv/salt/tests/files/Local.sls

SLS used

windows file test:
  file.recurse:
    - name: c:/test/
    - source: salt://tests/files
    - clean: True

result

root@salt00:/srv/salt/tests# salt amity state.apply tests.file
amity:
----------
          ID: windows file test
    Function: file.recurse
        Name: c:/test/
      Result: True
     Comment: Recursively updated c:/test/
     Started: 13:24:00.625507
    Duration: 189.0 ms
     Changes:
              ----------
              c:/test/Local.tst:
                  ----------
                  diff:
                      New file
              removed:
                  - c:\test\Local.tst

Summary for amity
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 189.000 ms

change the file.sls to the following and it works

windows file test:
  file.recurse:
    - name: c:\test\
    - source: salt://tests/files
    - clean: True

results 2x run

root@salt00:/srv/salt/tests# salt amity state.apply tests.file
amity:
----------
          ID: windows file test
    Function: file.recurse
        Name: c:\test\
      Result: True
     Comment: Recursively updated c:\test\
     Started: 13:25:37.283983
    Duration: 182.514 ms
     Changes:
              ----------
              c:\test\Local.tst:
                  ----------
                  diff:
                      New file

Summary for amity
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 182.514 ms
root@salt00:/srv/salt/tests# salt amity state.apply tests.file
amity:
----------
          ID: windows file test
    Function: file.recurse
        Name: c:\test\
      Result: True
     Comment: The directory c:\test\ is in the correct state
     Started: 13:25:41.750410
    Duration: 114.001 ms
     Changes:

Summary for amity
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time: 114.001 ms

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
root@salt00:/srv/salt/tests# salt amity test.versions
amity:
    Salt Version:
              Salt: 3004.2

    Dependency Versions:
              cffi: 1.14.6
          cherrypy: 18.6.1
          dateutil: 2.8.1
         docker-py: Not Installed
             gitdb: 4.0.7
         gitpython: 3.1.18
            Jinja2: 2.10.1
           libgit2: Not Installed
          M2Crypto: Not Installed
              Mako: 1.1.4
           msgpack: 0.6.2
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         pycparser: 2.20
          pycrypto: Not Installed
      pycryptodome: 3.10.1
            pygit2: Not Installed
            Python: 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)]
      python-gnupg: 0.4.7
            PyYAML: 5.4.1
             PyZMQ: 19.0.0
             smmap: 4.0.0
           timelib: 0.2.4
           Tornado: 4.5.3
               ZMQ: 4.3.2

    System Versions:
              dist:
            locale: cp1252
           machine: AMD64
           release: 10
            system: Windows
           version: 10 10.0.19041 SP0 Multiprocessor Free

Additional context
Add any other context about the problem here.

Ah... it's probably doing a compare and thinking that it's different because of the slashes...