gpt4 book ai didi

Ansible 无法设置临时文件的权限

转载 作者:行者123 更新时间:2023-12-04 03:26:08 25 4
gpt4 key购买 nike

我想制作一个剧本,向我展示当前正在使用的用户。

这是我的ansible cfg:

[defaults]
inventory=inventory
remote_user=adminek

[privilege_escalation]
become=true

[ssh_connection]
allow_world_readable_tmpfiles = True
ssh_args = -o ControlMaster=no -o ControlPath=none -o ControlPersist=no
pipelining = false

这是我的剧本

---
- name: show currenty users
hosts: server_a

tasks:
- name: test user - root
shell: "whoami"
register: myvar_root

- name: test user - user2
become: true
become_user: user2
shell: "whoami"
register: myvar_user2


- name: print myvar root
debug:
var: myvar_root.stdout_lines

- name: print myvar user2
debug:
var: myvar_user2.stdout

taks "test user - root"工作正常并给我输出

ok: [172.22.0.134] => {
"myvar_root.stdout_lines": [
"root"
]
}

taks "test user - user2"给我输出

fatal: [172.22.0.134]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership `/var/tmp/ansible-tmp-1621340458.2-11599-141854654478770/': Operation permited\nchown: changing ownership `/var/tmp/ansible-tmp-1621340458.2-11599-141854654478770/AnsiballZ_command.py': Operation permited\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}

解释:adminek- sudoer 用户User2 - 非 sudoers 用户

操作系统 - Scientific Linux 6.9 版

此外,我在 ubuntu 18.04 上遇到了类似的问题,但是当我安装 acl 时开始工作

有人知道怎么回事吗?感谢您的帮助!

最佳答案

以下选项之一应该可以解决您的问题:

  • 确保 sudo 安装在远程主机上
  • 确保 acl 安装在远程主机上
  • 取消注释 /etc/ansible/ansible.cfg 中的以下行:
allow_world_readable_tmpfiles = True
pipelining = True

关于Ansible 无法设置临时文件的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67587262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com