-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Open
Copy link
Labels
Bugbroken, incorrect, or confusing behaviorbroken, incorrect, or confusing behavior
Description
Description
While using file.recurse
with clean: true
to make sure the whole content of the specified directory is managed, the function is reporting changes, even though none are done/expected.
Setup
- salt-master (Debian 11)
- salt-minion (Debian 11)
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
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
- Create a state with the following content
clean_dir:
file.directory:
- name: /etc/ch-server
- user: root
- group: root
- mode: '0755'
- clean: true
{%- for file in [ 'one/1', '2', '3', '4', '5' ] %}
file_{{ file }}:
file.managed:
- name: /etc/ch-server/{{ file }}
- makedirs: true
- mode: '0600'
- dir_mode: '0750'
- replace: false
- require_in:
- file: clean_dir
{%- endfor %}
- Execute it (twice is probably easier to check the issue). The output is something like:
local:
----------
ID: file_one/1
Function: file.managed
Name: /etc/ch-server/one/1
Result: True
Comment: File /etc/ch-server/one/1 exists with proper permissions. No changes made.
Started: 15:23:21.694835
Duration: 3.348 ms
Changes:
----------
ID: file_2
Function: file.managed
Name: /etc/ch-server/2
Result: True
Comment: File /etc/ch-server/2 exists with proper permissions. No changes made.
Started: 15:23:21.698266
Duration: 0.624 ms
Changes:
----------
ID: file_3
Function: file.managed
Name: /etc/ch-server/3
Result: True
Comment: File /etc/ch-server/3 exists with proper permissions. No changes made.
Started: 15:23:21.698949
Duration: 0.556 ms
Changes:
----------
ID: file_4
Function: file.managed
Name: /etc/ch-server/4
Result: True
Comment: File /etc/ch-server/4 exists with proper permissions. No changes made.
Started: 15:23:21.699559
Duration: 1.371 ms
Changes:
----------
ID: file_5
Function: file.managed
Name: /etc/ch-server/5
Result: True
Comment: File /etc/ch-server/5 exists with proper permissions. No changes made.
Started: 15:23:21.701127
Duration: 1.01 ms
Changes:
----------
ID: clean_dir
Function: file.directory
Name: /etc/ch-server
Result: True
Comment: Directory /etc/ch-server updated
Started: 15:23:21.702372
Duration: 1.755 ms
Changes:
----------
/etc/ch-server/one:
----------
removed:
Removed due to clean
Summary for local
------------
Succeeded: 6 (changed=1)
Failed: 0
------------
Total states run: 6
Total run time: 8.664 ms
- Check the folder to be removed is still there and has not been touched since it was created
# stat /etc/ch-server/one
File: /etc/ch-server/one
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 803h/2051d Inode: 3802404 Links: 2
Access: (0750/drwxr-x---) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2025-06-03 15:22:58.228055902 +0000
Modify: 2025-06-03 15:22:58.188035901 +0000
Change: 2025-06-03 15:22:58.188035901 +0000
Birth: 2025-06-03 15:22:58.188035901 +0000
Expected behavior
The folder is not expected to be removed since there is a file within it that is managed by file.managed
with require
in place (one/1
) as well as no changes are expected while running the state.
Versions Report
Salt Version:
Salt: 3007.2
Python Version:
Python: 3.10.17 (main, Apr 14 2025, 21:37:11) [GCC 11.2.0]
Dependency Versions:
cffi: 1.16.0
cherrypy: 18.8.0
cryptography: 42.0.5
dateutil: 2.8.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.6
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.7
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.5.2
PyYAML: 6.0.1
PyZMQ: 25.1.2
relenv: 0.19.0
smmap: Not Installed
timelib: 0.3.0
Tornado: 6.4.2
ZMQ: 4.3.4
Salt Package Information:
Package Type: onedir
System Versions:
dist: debian 11.8 bullseye
locale: utf-8
machine: x86_64
release: 5.10.0-27-amd64
system: Linux
version: Debian GNU/Linux 11.8 bullseye
Additional context
Confirmed as an issue in both Salt 3007.2 and Debian 11 as well as 3006.8 and Debian 12.
Metadata
Metadata
Assignees
Labels
Bugbroken, incorrect, or confusing behaviorbroken, incorrect, or confusing behavior