ansible常用模块之 -- acl模块 -- 设置和检索文件ACL信息

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值