尝试获得 ansible 文件/目录权限以工作。
在 ansible 中我创建了一个用户:
user: name=testuser shell=/sbin/nologin uid=1234 comment="Test User"
然后我尝试更改文件目录的所有权:
file: path=/etc/myfile state=directory owner=testuser group=testuser mode=0644 recurse=yes
我也试过为文件设置 facl:
acl:
name: /var/log/audit/audit.log
entity: filebeat
etype: user
permissions: rx
state: present
观察文件权限和 facl 时,它们似乎设置正确。但是,如果我更改测试用户的 shell 并登录,我发现我实际上并没有 ansible 可能设置的权限。我不断收到“权限被拒绝”消息。
最佳答案
如果我明白你的意思,当你尝试访问目录内容时,你会得到“权限被拒绝”,例如运行 ls -l/etc/myfile
。
这是正确的 *nix 行为,因为您将访问权限设置为 mode=0644
。
关于目录,执行位允许受影响的用户进入目录,并访问里面的文件和目录。
因此,要允许您的测试用户浏览目录,请至少设置 mode=0744
。
允许测试用户组 mode=0754
并允许所有人 mode=0755
关于linux - ansible文件和目录权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39373006/