Attempt 1:I'm trying to run the following task, but it doesn't work because ansible isn't providing the password to the host and it sits there until it times out:task:- name: apply configurator on {{ inventory_hostname }}become: falseshell: "sudo /usr/bin/do-something"output:<times-out>Attempt 2:I then tried to run the following task, but it doesn't work because it runs as user2, but that's not what I want because user2 doesn't have sudo privs:task:- name: apply configurator on {{ inventory_hostname }}become: trueshell: "/usr/bin/do-something"output:fatal: [host]: FAILED! => {"changed": true, "cmd": "/usr/bin/do-something", "delta": "0:00:00.027783", "end": "2018-03-01 21:46:58.719945", "msg": "non-zero return code", "rc": 126, "start": "2018-03-01 21:46:58.692162", "stderr": "/bin/sh: /usr/bin/do-something: Permission denied", "stderr_lines": ["/bin/sh: /usr/bin/do-something: Permission denied"], "stdout": "", "stdout_lines": []}Attempt 3:I then try to run the following task, but it hangs as it waits for credentials for user2's password, which ansible will not provide (even it it worked):task:- name: apply configurator on {{ inventory_hostname }}become: trueshell: "sudo /usr/bin/do-something"output:<times-out>
I've even tried setting the become_user to user1, but that doesn't work either. Using "sudo" in the shell command causes it to hang because a prompt for password is waiting whereas keeping "sudo" out gets me another permission error.Any help is greatly appreciated.Thanks,Kevin
ansible_become_user: user2
- name: Configurator command needs to be run
become_user: root
shell: "/usr/bin/do-something"
become_user: user2