Reputation: 527
I need to set the permissions of the files under a directory but I don't want to change the permission of the directory.
I tried this:
- name: chmod 444
file: /dir recurse=yes state=directory owner=abc group=abc mode=0444
But it will modify the directory permission also. Is it possible?
Upvotes: 1
Views: 5928
Reputation: 1
in one task using shell:
- shell: "find . -type f -exec chmod 0444 {} \\;"
args:
chdir: /dir
Upvotes: 0
Reputation: 68559
Not in one task.
You need first to find files and then execute the file
module with the appropriate settings against the list.
- find:
path: /dir
file_type: file
recurse: yes
register: find_result
- file:
path: "{{ item.path }}"
owner: abc
group: abc
mode: 0444
with_items: "{{ find_result.files }}"
Upvotes: 2