Ansible递归授予对文件的只读访问权限
Ansible recursively grant read-only access to files
我有一个目录 /read-only-others-group
,其中 others
组中的用户应该对所有文件具有递归的只读访问权限。我尝试使用 file 模块:
- name: Ensure /read-only-others-group directory exists and gives read-only access to others group
file:
path: /read-only-others-group
state: directory
recurse: yes
owner: someuser
group: somegroup
mode: "0754"
此权限不允许其他组中的用户 ls
或 cat
文件或 cd
进入目录或其下的任何内容。
可以用 shell 模块解决,例如:
find /read-only-others-group -type d -print0 | xargs -0 chmod 755
find /read-only-others-group -type f -print0 | xargs -0 chmod 754
是否有更好的幂等解决方案?
问:"其他组中的用户应具有只读访问权限"
答:使用symbolic mode
mode: "o-w"
我有一个目录 /read-only-others-group
,其中 others
组中的用户应该对所有文件具有递归的只读访问权限。我尝试使用 file 模块:
- name: Ensure /read-only-others-group directory exists and gives read-only access to others group
file:
path: /read-only-others-group
state: directory
recurse: yes
owner: someuser
group: somegroup
mode: "0754"
此权限不允许其他组中的用户 ls
或 cat
文件或 cd
进入目录或其下的任何内容。
可以用 shell 模块解决,例如:
find /read-only-others-group -type d -print0 | xargs -0 chmod 755
find /read-only-others-group -type f -print0 | xargs -0 chmod 754
是否有更好的幂等解决方案?
问:"其他组中的用户应具有只读访问权限"
答:使用symbolic mode
mode: "o-w"