diff --git a/changelogs/fragments/async-wrapper-stdin.yaml b/changelogs/fragments/async-wrapper-stdin.yaml new file mode 100644 index 0000000000..ed9c1d638b --- /dev/null +++ b/changelogs/fragments/async-wrapper-stdin.yaml @@ -0,0 +1,2 @@ +bugfixes: +- async_wrapper - Allocate an explicit stdin (https://github.com/ansible/ansible/issues/50758) diff --git a/lib/ansible/modules/utilities/logic/async_wrapper.py b/lib/ansible/modules/utilities/logic/async_wrapper.py index d97e0b1d40..586438ff13 100644 --- a/lib/ansible/modules/utilities/logic/async_wrapper.py +++ b/lib/ansible/modules/utilities/logic/async_wrapper.py @@ -148,7 +148,8 @@ def _run_module(wrapped_cmd, jid, job_path): interpreter = _get_interpreter(cmd[0]) if interpreter: cmd = interpreter + cmd - script = subprocess.Popen(cmd, shell=False, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + script = subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) (outdata, stderr) = script.communicate() if PY3: diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml index 571a632c08..f84ad9b3f3 100644 --- a/test/integration/targets/async/tasks/main.yml +++ b/test/integration/targets/async/tasks/main.yml @@ -280,3 +280,9 @@ file: path: '{{ custom_async_tmp }}' state: absent + +- name: Test that async has stdin + command: > + {{ ansible_python_interpreter|default('/usr/bin/python') }} -c 'import os; os.fdopen(os.dup(0), "r")' + async: 1 + poll: 1