[BUG] file.directory ignores test=true and removes symlink
Description Despite test=true, file.directory state is deleting a symlink
Setup
dir_check:
file.directory:
- name: /tmp/dest_folder
- allow_symlink: False
- force: True
Please be as specific as possible and give set-up details.
- [x] on-prem machine
mkdir /tmp/source_folder
ln -s /tmp/source_folder /tmp/dest_folder
Steps to Reproduce the behavior
Running the state via CLI equivalent:
sudo salt-call state.single file.directory name="/tmp/dest_folder" allow_symlink=False force=True test=true
returns
----------
ID: /tmp/dest_folder
Function: file.directory
Result: True
Comment: The directory /tmp/dest_folder is in the correct state
Started: 16:47:12.778895
Duration: 6.571 ms
Changes:
----------
forced:
Symlink would be forcibly replaced
Summary for local
------------
But running the above state.apply test=true returns
----------
ID: luts_local_dir_check
Function: file.directory
Name: /tmp/dest_folder
Result: None
Comment: The following files will be changed:
/tmp/dest_folder: directory - new
Started: 16:46:40.176155
Duration: 1.033 ms
Changes:
----------
/tmp/dest_folder:
----------
directory:
new
----------
Expected behavior I expect the state.apply test=true not to modify the minion's filesystem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)salt --versions-report
Salt Version:
Salt: 3006.1
Python Version:
Python: 3.10.11 (main, May 5 2023, 02:31:54) [GCC 11.2.0]
Dependency Versions:
cffi: 1.14.6
cherrypy: unknown
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.9.8
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 5.4.1
PyZMQ: 23.2.0
relenv: 0.12.3
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rocky 8.4 Green Obsidian
locale: utf-8
machine: x86_64
release: 4.18.0-305.3.1.el8_4.x86_64
system: Linux
version: Rocky Linux 8.4 Green Obsidian
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
- Community Wiki
- Salt’s Contributor Guide
- Join our Community Slack
- IRC on LiberaChat
- Salt Project YouTube channel
- Salt Project Twitch channel
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
I'm not able to reproduce, neither on 3006.1 nor the head of the 3006.x branch.
Apologies @terminalmage , looks like it only happens when "backupname" is present:
mkdir /tmp/source_folder
ln -s /tmp/source_folder /tmp/dest_folder
dir_check:
file.directory:
- name: /tmp/dest_folder
- allow_symlink: False
- force: True
- backupname: /tmp/saved
sudo salt-call --local state.sls dir_check test=True
@groucho86 That helps! I have found the bug. I will have a PR open in the next day or two.
@groucho86 see #66120.