Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible Failed to set permissions on the temporary files

I'd like to make a playbook that shows me the user currently in use.

this is my 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

and this is my playbook

---
- 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" work fine and give me output

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

taks "test user - user2" give me output

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"}

Explanation: adminek- sudoer user User2 - non sudoers users

OS - Scientific Linux release 6.9

Additionaly I hgad similar problem on ubuntu 18.04 but when i installed acl begun works

Someone know what is wrong? Thanks for help!

like image 792
bartek lab Avatar asked Oct 20 '25 16:10

bartek lab


1 Answers

One of the following options should fix your issue:

  • Ensure sudo is installed on the remote host
  • Ensure acl is installed on the remote host
  • Uncomment the following lines in /etc/ansible/ansible.cfg:
allow_world_readable_tmpfiles = True
pipelining = True
like image 135
F1ko Avatar answered Oct 23 '25 08:10

F1ko