diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 42bcb415dd8..455de0fc82a 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -263,6 +263,8 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks): super(CliRunnerCallbacks, self).on_async_failed(host,res,jid) def _on_any(self, host, result): + result2 = result.copy() + result2.pop('invocation', None) print host_report_msg(host, self.options.module_name, result, self.options.one_line) if self.options.tree: utils.write_tree_file(self.options.tree, host, utils.jsonify(result,format=True)) @@ -288,6 +290,10 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): super(PlaybookRunnerCallbacks, self).on_unreachable(host, msg) def on_failed(self, host, results, ignore_errors=False): + + results = results.copy() + results.pop('invocation', None) + item = results.get('item', None) if item: msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results)) @@ -301,6 +307,9 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): def on_ok(self, host, host_result): item = host_result.get('item', None) + host_result = host_result.copy() + host_result.pop('invocation', None) + # show verbose output for non-setup module results if --verbose is used msg = '' if not self.verbose or host_result.get("verbose_override",None) is not None: diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 6b7503aa498..4a2d005efbc 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -573,7 +573,6 @@ class Runner(object): else: result = self._execute_async_module(conn, tmp, module_name, inject=inject) - result.result['module'] = self.module_name if result.is_successful() and 'daisychain' in result.result: self.module_name = result.result['daisychain'] if 'daisychain_args' in result.result: @@ -584,7 +583,6 @@ class Runner(object): self.module_name = prev_module_name self.module_args = prev_module_args - result2.result['module'] = self.module_name changed = False if result.result.get('changed',False) or result2.result.get('changed',False): changed = True @@ -604,6 +602,12 @@ class Runner(object): data = result.result if 'item' in inject: result.result['item'] = inject['item'] + + result.result['invocation'] = dict( + module_args=self.module_args, + module_name=self.module_name + ) + if is_chained: # no callbacks return result