diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index f6a914097c3..b838b465dad 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -538,8 +538,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