开发者社区> 问答> 正文

使用ansible修改/etc/shadow文件的acl权限失败

已解决

我使用ansible修改其他配置文件时都可以修改,在修改/etc/shadow文件时会报错:
setfacl: /etc/shadow: Operation not permittednon-zero return code
setfacl: /etc/shadow: Operation not permitted
请问怎样才能使用ansible来修改/etc/shadow文件的acl权限呢?

我使用shell模块 ansible test1 -m shell -a 'setfacl -m user:aiuap:r /etc/shadow'
如下报错
10.124.210.222 | FAILED | rc=1 >>
setfacl: /etc/shadow: Operation not permittednon-zero return code

我使用acl模块 ansible test1-m acl -a 'path=/etc/shadow entity=test etype=user permissions=r state=present'
如下报错
10.124.210.222 | FAILED! => {

"changed": false, 
"cmd": "/usr/bin/setfacl -m user:test:r /etc/shadow", 
"msg": "setfacl: /etc/shadow: Operation not permitted", 
"rc": 1, 
"stderr": "setfacl: /etc/shadow: Operation not permitted\n", 
"stderr_lines": [
    "setfacl: /etc/shadow: Operation not permitted"
], 
"stdout": "", 
"stdout_lines": []

}

我使用script模块 ansible test1 -m script -a './acl.sh'
提示成功,但是实际上并未修改/etc/shadow的文件acl权限.
10.124.210.222 | SUCCESS => {

"changed": true, 
"rc": 0, 
"stderr": "Shared connection to 10.124.210.222 closed.\r\n", 
"stderr_lines": [
    "Shared connection to 10.124.210.222 closed."
], 
"stdout": "setfacl: /etc/shadow: Operation not permitted\r\ngetfacl: Removing leading '/' from absolute path 

namesrn# file: etc/shadowrn# owner: rootrn# group: rootrnuser::---rngroup::---rnother::---rnrn", "stdout_lines": [

    "setfacl: /etc/shadow: Operation not permitted", 
    "getfacl: Removing leading '/' from absolute path names", 
    "# file: etc/shadow", 
    "# owner: root", 
    "# group: root", 
    "user::---", 
    "group::---", 
    "other::---", 
    ""
]

}

展开
收起
祝小祝 2018-12-17 13:15:57 5236 0
1 条回答
写回答
取消 提交回答
  • 采纳回答

    试试增加参数--become-user=root

    2019-07-17 23:22:30
    赞同 1 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
ANSIBLE在生产环境中的实践 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载