Warm tip: This article is reproduced from serverfault.com, please click

其他-Ansible递归授予对文件的只读访问权限

(其他 - Ansible recursively grant read-only access to files)

发布于 2020-12-04 10:17:02

我有一个目录/read-only-others-group,其中others中的用户应以递归方式对所有文件具有只读访问权限。我尝试了文件模块:

- 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"

此权限不允许其他组lscat文件中的用户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

有没有更好的,幂等的解决方案?

Questioner
moazzem
Viewed
0
Vladimir Botka 2020-12-04 18:49:40

问:其他组中的用户应具有只读访问权限

答:使用符号模式

    mode: "o-w"