【问题标题】:Ansible recursively grant read-only access to filesAnsible 递归授予对文件的只读访问权限
【发布时间】:2021-03-16 09:34:11
【问题描述】:

我有一个目录/read-only-others-groupothers 组中的用户应该对所有文件具有递归的只读访问权限。我尝试使用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"

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

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

【问题讨论】:

    标签: ansible file-permissions ansible-2.x


    【解决方案1】:

    问:其他组的用户应该有只读权限

    答:使用symbolic mode

        mode: "o-w"
    

    【讨论】:

      猜你喜欢
      • 2011-04-23
      • 2017-04-07
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 2021-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多