From d36394d6a64ff9b394405c0cd53dcacb65404cd4 Mon Sep 17 00:00:00 2001 From: Matthew Stoltenberg Date: Tue, 9 Feb 2016 09:18:09 -0700 Subject: [PATCH] strip BECOME-SUCCESS at lower level Fixes #14395 --- lib/ansible/plugins/action/__init__.py | 4 +++- lib/ansible/plugins/action/async.py | 4 ---- lib/ansible/plugins/action/raw.py | 5 ----- lib/ansible/plugins/action/script.py | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index cc2afdc8651..78c7e809bb1 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -544,8 +544,10 @@ class ActionBase(with_metaclass(ABCMeta, object)): if rc is None: rc = 0 - display.debug("_low_level_execute_command() done: rc=%d, stdout=%s, stderr=%s" % (rc, stdout, stderr)) + # be sure to remove the BECOME-SUCCESS message now + out = self._strip_success_message(out) + display.debug("_low_level_execute_command() done: rc=%d, stdout=%s, stderr=%s" % (rc, stdout, stderr)) return dict(rc=rc, stdout=out, stdout_lines=out.splitlines(), stderr=err) def _get_first_available_file(self, faf, of=None, searchdir='files'): diff --git a/lib/ansible/plugins/action/async.py b/lib/ansible/plugins/action/async.py index 5e04f37ff12..8a7175aeb86 100644 --- a/lib/ansible/plugins/action/async.py +++ b/lib/ansible/plugins/action/async.py @@ -75,8 +75,4 @@ class ActionModule(ActionBase): result['changed'] = True - # be sure to strip out the BECOME-SUCCESS message, which may - # be there depending on the output of the module - result['stdout'] = self._strip_success_message(result.get('stdout', '')) - return result diff --git a/lib/ansible/plugins/action/raw.py b/lib/ansible/plugins/action/raw.py index c9718db4135..a76e6d6c3c2 100644 --- a/lib/ansible/plugins/action/raw.py +++ b/lib/ansible/plugins/action/raw.py @@ -37,9 +37,4 @@ class ActionModule(ActionBase): executable = self._task.args.get('executable') result.update(self._low_level_execute_command(self._task.args.get('_raw_params'), executable=executable)) - # for some modules (script, raw), the sudo success key - # may leak into the stdout due to the way the sudo/su - # command is constructed, so we filter that out here - result['stdout'] = self._strip_success_message(result.get('stdout', '')) - return result diff --git a/lib/ansible/plugins/action/script.py b/lib/ansible/plugins/action/script.py index f1ff2703efa..5b0f324dfcf 100644 --- a/lib/ansible/plugins/action/script.py +++ b/lib/ansible/plugins/action/script.py @@ -97,7 +97,6 @@ class ActionModule(ActionBase): if tmp and "tmp" in tmp and not C.DEFAULT_KEEP_REMOTE_FILES: self._remove_tmp_path(tmp) - result['stdout'] = self._strip_success_message(result.get('stdout', '')) result['changed'] = True return result