1
votes

I get puzzled a lot of time with the following issue.

I try so launch a process (here just a silly java -version) using async feature.

I run the ansible-playbook using my user which has a remote account as sudoer in the docker host. The other account with which I'd like to start the command is toto

So I wrote this

- name: test escalation
  shell: id ; echo "shell says toto"
  become: true
  become_user: "toto"
  tags:
    - escalation
  vars:
    ansible_ssh_pipelining: true

- name: java escalation
  shell:
    cmd: "/data/tools/java/jdk8u232-b09/bin/java -version &"
  async: 10
  # Don't wait
  poll: 0
  become: true
  become_user: "toto"
  tags:
    - escalation
  vars:
    ansible_ssh_pipelining: true

If i run this, I have

TASK [java escalation] ************************************************************************************************************ fatal: [main]: 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 of '/var/tmp/ansible-tmp-1587484730.23-27264-164045960304097/': Operation not permitted\nchown: changing ownership of '/var/tmp/ansible-tmp-1587484730.23-27264-164045960304097/AnsiballZ_command.py': Operation not permitted\nchown: changing ownership of '/var/tmp/ansible-tmp-1587484730.23-27264-164045960304097/async_wrapper.py': Operation not permitted\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}

Did anybody had the same issue ?

ansible --version ansible 2.9.7

1
I just have the same issue, only in combination with async. BTW i was on 2.9.4, but in 2.9.7 as you stated it does not work either.MrTango

1 Answers

1
votes

If I do not use the async feature (I can use any value for poll)

- name: java escalation
  shell:
    cmd: "/data/tools/java/jdk8u232-b09/bin/java -version &"
  # async: 10
  # Don't wait
  poll: 0
  become: true
  become_user: "toto"
  tags:
    - escalation
  vars:
    ansible_ssh_pipelining: true

It works fine

TASK [ java escalation] ************************************************************************************************************ changed: [main] => {"changed": true, "cmd": "/data/tools/java/jdk8u232-b09/bin/java -version &", "delta": "0:00:00.034427", "end": "2020-04-21 15:59:46.402081", "rc": 0, "start": "2020-04-21 15:59:46.367654", "stderr": "openjdk version \"1.8.0_232\"\nOpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)\nOpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)", "stderr_lines": ["openjdk version \"1.8.0_232\"", "OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)", "OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)"], "stdout": "", "stdout_lines": []}