ansible常用模块之 -- acl模块 -- 设置和检索文件ACL信息
acl模块 – 设置和检索文件ACL信息
一、摘要
- 设置和检索文件ACL信息
二、参数
参数 | 选项/默认值 | 描述 |
---|---|---|
default boolean | · no ← · yes | 如果目标是一个目录,将其设置为yes将使其成为目录内创建的实体的默认ACL。 如果路径是文件,则将default设置为yes会导致错误。 |
entity | 在匹配实体类型时,选择ACL所应用的实际用户或组。 | |
etype | · group · mask · other · user | 要应用的ACL的实体类型,有关更多信息,请参阅setfacl文档。 |
follow boolean | · yes ← · no | 如果遇到符号链接,是否遵循路径上的符号链接。 |
path path required | 文件或对象的完整路径。 | |
permissions | 应用/删除的权限可以是r、w和x的任意组合(分别是读、写和执行) | |
recalculate_mask | · default ← · mask · no_mask | 选择是否以及何时重新计算文件的有效权限掩码。 更多信息请参见setfacl文档。 与 state=query 冲突 |
recursive boolean | · no ← · yes | 递归地设置指定的ACL。 与 state=query 冲突 |
state | · absent · present · query ← | 定义ACL是否应该出现。 state-query 获得当前ACL而不更改它,以便在寄存器操作中使用。 |
use_nfsv4_acls boolean | · no ← · yes | 使用NFSv4 acl代替POSIX acl。 |
三、示例
# 授予用户Joe对文件的读访问权限
- name: Grant user Joe read access to a file
acl:
path: /etc/foo.conf
entity: joe
etype: user
permissions: r
state: present
# 移除特定文件上Joe的ACL
- name: Removes the ACL for Joe on a specific file
acl:
path: /etc/foo.conf
entity: joe
etype: user
state: absent
# 为joe在/etc/foo.d/上设置默认ACL
- name: Sets default ACL for joe on /etc/foo.d/
acl:
path: /etc/foo.d/
entity: joe
etype: user
permissions: rw
default: yes
state: present
# 与前面相同,但使用了输入简写
- name: Same as previous but using entry shorthand
acl:
path: /etc/foo.d/
entry: default:user:joe:rw-
state: present
# 获取指定文件的ACL
- name: Obtain the ACL for a specific file
acl:
path: /etc/foo.conf
register: acl_info
官方文档:https://docs.ansible.com/ansible/2.9/modules/acl_module.html#acl-module