Store invocation differently from an API perspective, but hide in callbacks

This commit is contained in:
Michael DeHaan 2012-08-20 20:41:28 -04:00
parent 1ca6335323
commit bf92a9e4e0
2 changed files with 15 additions and 2 deletions

View file

@ -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:

View file

@ -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