ansible.builtin.file fails to change permissions on hard links unless you explicitly define 'state: file' #76142
Labels
affects_2.13
bug
This issue/PR relates to a bug.
has_pr
This issue has an associated PR.
module
This issue/PR relates to a module.
P3
Priority 3 - Approved, No Time Limitation
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
Summary
When using the file module to iterate over a list of files, some of which could be hardlinks, the file module fails with "src is required for creating new hardlinks" However, I am simply trying to modify the permissions of the files, not create new ones.
For example, I gather the list of files like so (keep in mind some of these are regular files, some of them are hardlinks):
So at this point,
crt_find
is a list of files and hard links.Then, I iterate over
crt_find
to set the permissions on all of the files and hardlinks using the file module:This works perfectly fine for regular files. When it gets to a hardlink, it fails with "src is required for creating new hardlinks." The problem is, I'm not trying to create a new hardlink. I'm simply trying to modify the permissions.
Interestingly, this goes away if I explicitly define
state: file
as a parameter on the file module task:While I've clearly found a solution to my problem, it definitely seems like a bug with the file module, as
state: file
is the default if omitted.Issue Type
Bug Report
Component Name
ansible.builtin.file
Ansible Version
Configuration
OS / Environment
Control machine = MacOS
Target machine = Ubuntu 20
Steps to Reproduce
Stated in the Summary
Expected Results
Stated in the Summary
Actual Results
Stated in the Summary
Code of Conduct
The text was updated successfully, but these errors were encountered: