Store invocation differently from an API perspective, but hide in callbacks
This commit is contained in:
parent
1ca6335323
commit
bf92a9e4e0
2 changed files with 15 additions and 2 deletions
|
@ -263,6 +263,8 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
|
||||||
super(CliRunnerCallbacks, self).on_async_failed(host,res,jid)
|
super(CliRunnerCallbacks, self).on_async_failed(host,res,jid)
|
||||||
|
|
||||||
def _on_any(self, host, result):
|
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)
|
print host_report_msg(host, self.options.module_name, result, self.options.one_line)
|
||||||
if self.options.tree:
|
if self.options.tree:
|
||||||
utils.write_tree_file(self.options.tree, host, utils.jsonify(result,format=True))
|
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)
|
super(PlaybookRunnerCallbacks, self).on_unreachable(host, msg)
|
||||||
|
|
||||||
def on_failed(self, host, results, ignore_errors=False):
|
def on_failed(self, host, results, ignore_errors=False):
|
||||||
|
|
||||||
|
results = results.copy()
|
||||||
|
results.pop('invocation', None)
|
||||||
|
|
||||||
item = results.get('item', None)
|
item = results.get('item', None)
|
||||||
if item:
|
if item:
|
||||||
msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results))
|
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):
|
def on_ok(self, host, host_result):
|
||||||
item = host_result.get('item', None)
|
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
|
# show verbose output for non-setup module results if --verbose is used
|
||||||
msg = ''
|
msg = ''
|
||||||
if not self.verbose or host_result.get("verbose_override",None) is not None:
|
if not self.verbose or host_result.get("verbose_override",None) is not None:
|
||||||
|
|
|
@ -573,7 +573,6 @@ class Runner(object):
|
||||||
else:
|
else:
|
||||||
result = self._execute_async_module(conn, tmp, module_name, inject=inject)
|
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:
|
if result.is_successful() and 'daisychain' in result.result:
|
||||||
self.module_name = result.result['daisychain']
|
self.module_name = result.result['daisychain']
|
||||||
if 'daisychain_args' in result.result:
|
if 'daisychain_args' in result.result:
|
||||||
|
@ -584,7 +583,6 @@ class Runner(object):
|
||||||
self.module_name = prev_module_name
|
self.module_name = prev_module_name
|
||||||
self.module_args = prev_module_args
|
self.module_args = prev_module_args
|
||||||
|
|
||||||
result2.result['module'] = self.module_name
|
|
||||||
changed = False
|
changed = False
|
||||||
if result.result.get('changed',False) or result2.result.get('changed',False):
|
if result.result.get('changed',False) or result2.result.get('changed',False):
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -604,6 +602,12 @@ class Runner(object):
|
||||||
data = result.result
|
data = result.result
|
||||||
if 'item' in inject:
|
if 'item' in inject:
|
||||||
result.result['item'] = inject['item']
|
result.result['item'] = inject['item']
|
||||||
|
|
||||||
|
result.result['invocation'] = dict(
|
||||||
|
module_args=self.module_args,
|
||||||
|
module_name=self.module_name
|
||||||
|
)
|
||||||
|
|
||||||
if is_chained:
|
if is_chained:
|
||||||
# no callbacks
|
# no callbacks
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue