无法设置 Ansible 需要创建的临时文件的权限

use*_*443 5 ansible ansible-2.x

我有两个 Ansible 角色需要become_user非特权用户(例如设置 git 答案和dconf dump当前设置);我已经allow_world_readable_tmpfiles=Trueansible.cfg文件中设置了,但仍然有错误消息

Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of '/var/tmp/ansible-tmp-1613484534.333031-12971-165984005608584/': Operation not permitted
     chown: changing ownership of '/var/tmp/ansible-tmp-1613484534.333031-12971-165984005608584/AnsiballZ_command.py': Operation not permitted
Run Code Online (Sandbox Code Playgroud)

我不使用 ACL 或类似的东西(并且不想),并且我不知道如何以特权用户身份运行。我对文档的理解是,自 Ansble 2.1 版本以来,该问题不应该存在。

我在 64 位 aarch64 (raspi 4) 上运行,内核为 5.8.0.-1015。ansible 是: Ansible 2.9.9 配置文件 = /home/frank/Data/ansibleHost/ansible.cfg 配置的模块搜索路径 = ['/home/frank/.ansible/plugins/modules', '/usr/share/ansible/ plugins/modules'] ansible python 模块位置 = /usr/lib/python3/dist-packages/ansible 可执行文件位置 = /usr/bin/ansible python 版本 = 3.8.6 (默认,2020 年 9 月 25 日,09:36:53) [海湾合作委员会10.2.0]

导致错误的任务是:

- name: write a dconf dump file before loading
  shell: dconf dump / > "{{remoteDir}}current"
  become: True
  become_user: "{{ this_user.user_name }}"
  environment:
    DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/{{ this_user.user_uid }}/bus 
Run Code Online (Sandbox Code Playgroud)

它在新安装的 Debian bullseye (python3) 上运行。

bba*_*iee 0

您可以通过配置解决此问题,例如:

[defaults]
inventory = inventory
callbacks_enabled = profile_tasks,timer
remote_tmp = /var/${USER}/ansible
Run Code Online (Sandbox Code Playgroud)

角色或剧本中的典型用法是become_user: postgres