Ansible:更改文件的权限,但不更改目录的权限
我需要设置目录下文件的权限,但我不想更改目录的权限 我试过这个:Ansible:更改文件的权限,但不更改目录的权限,ansible,ansible-2.x,Ansible,Ansible 2.x,我需要设置目录下文件的权限,但我不想更改目录的权限 我试过这个: - name: chmod 444 file: /dir recurse=yes state=directory owner=abc group=abc mode=0444 但它也会修改目录权限。可能吗?不是一项任务 您需要首先查找文件,然后根据列表执行带有适当设置的文件模块 - find: path: /dir file_type: file recurse: yes register: fin
- name: chmod 444
file: /dir recurse=yes state=directory owner=abc group=abc mode=0444
但它也会修改目录权限。可能吗?不是一项任务
您需要首先查找文件,然后根据列表执行带有适当设置的文件
模块
- 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 }}"
在一个使用shell的任务中:
- shell: "find . -type f -exec chmod 0444 {} \\;"
args:
chdir: /dir
请查看帮助中心:。