From 264d9a9008863bc6581d8d4a133f15cd615fe413 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 7 Mar 2019 09:28:44 -0600 Subject: [PATCH] Allocate an explicit stdin in async_wrapper (#53410) * add changelog fragment * Add stdin async test * Allocate an explicit stdin in async_wrapper. Fixes #50758 --- changelogs/fragments/async-wrapper-stdin.yaml | 2 ++ lib/ansible/modules/utilities/logic/async_wrapper.py | 3 ++- test/integration/targets/async/tasks/main.yml | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/async-wrapper-stdin.yaml 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