From 1c955a98768c07de68bb6705f8f4dc1c5afeea86 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 13 Feb 2019 03:36:39 +0000 Subject: [PATCH] ansible: capture stderr stream of async tasks. Closes #540. --- ansible_mitogen/target.py | 2 +- docs/changelog.rst | 3 +++ tests/ansible/integration/async/result_shell_echo_hi.yml | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ansible_mitogen/target.py b/ansible_mitogen/target.py index 58b715ce..e891730e 100644 --- a/ansible_mitogen/target.py +++ b/ansible_mitogen/target.py @@ -502,7 +502,7 @@ class AsyncRunner(object): ) result = json.loads(filtered) result.setdefault('warnings', []).extend(warnings) - result['stderr'] = dct['stderr'] + result['stderr'] = dct['stderr'] or result.get('stderr', '') self._update(result) def _run(self): diff --git a/docs/changelog.rst b/docs/changelog.rst index b037ace1..e7ce61c3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -144,6 +144,9 @@ Fixes * `#538 `_: the Mitogen source distribution includes a requisite ``LICENSE`` file. +* `#540 `_: the ``stderr`` stream of + async module invocations was previously discarded. + * `748f5f67 `_: the ``ansible_ssh_host`` variable is respected when ``mitogen_via=`` is active. diff --git a/tests/ansible/integration/async/result_shell_echo_hi.yml b/tests/ansible/integration/async/result_shell_echo_hi.yml index c2d2dc42..e1068587 100644 --- a/tests/ansible/integration/async/result_shell_echo_hi.yml +++ b/tests/ansible/integration/async/result_shell_echo_hi.yml @@ -5,7 +5,7 @@ any_errors_fatal: true tasks: - - shell: echo hi + - shell: echo hi; echo there >&2 async: 100 poll: 0 register: job @@ -21,10 +21,10 @@ - assert: that: - async_out.changed == True - - async_out.cmd == "echo hi" + - async_out.cmd == "echo hi; echo there >&2" - 'async_out.delta.startswith("0:00:")' - async_out.end.startswith("20") - - async_out.invocation.module_args._raw_params == "echo hi" + - async_out.invocation.module_args._raw_params == "echo hi; echo there >&2" - async_out.invocation.module_args._uses_shell == True - async_out.invocation.module_args.chdir == None - async_out.invocation.module_args.creates == None @@ -33,7 +33,7 @@ - async_out.invocation.module_args.warn == True - async_out.rc == 0 - async_out.start.startswith("20") - - async_out.stderr == "" + - async_out.stderr == "there" - async_out.stdout == "hi" vars: async_out: "{{result.content|b64decode|from_json}}"