1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #639 from goozbach/issue-627

improved output in with_items fixes: #627
This commit is contained in:
Michael DeHaan 2012-07-20 16:36:49 -07:00
commit b0eedfbf92
2 changed files with 30 additions and 6 deletions

View file

@ -248,22 +248,45 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
def on_unreachable(self, host, msg): def on_unreachable(self, host, msg):
item = msg.get('item', None)
if item:
print "fatal: [%s] => (item=%s) => %s" % (host, item, msg)
else:
print "fatal: [%s] => %s" % (host, msg) print "fatal: [%s] => %s" % (host, msg)
def on_failed(self, host, results): def on_failed(self, host, results):
item = results.get('item', None)
if item:
print "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results))
else:
print "failed: [%s] => %s" % (host, utils.jsonify(results)) print "failed: [%s] => %s" % (host, utils.jsonify(results))
def on_ok(self, host, host_result): def on_ok(self, host, host_result):
item = host_result.get('item', 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
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:
if item:
print "ok: [%s] => (item=%s)" % (host,item)
else:
print "ok: [%s]" % (host) print "ok: [%s]" % (host)
else:
if item:
print "ok: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(host_result))
else: else:
print "ok: [%s] => %s" % (host, utils.jsonify(host_result)) print "ok: [%s] => %s" % (host, utils.jsonify(host_result))
def on_error(self, host, err): def on_error(self, host, err):
item = err.get('item', None)
if item:
print >>sys.stderr, "err: [%s] => (item=%s) => %s" % (host, item, err)
else:
print >>sys.stderr, "err: [%s] => %s" % (host, err) print >>sys.stderr, "err: [%s] => %s" % (host, err)
def on_skipped(self, host): def on_skipped(self, host):

View file

@ -646,6 +646,7 @@ class Runner(object):
self.callbacks.on_unreachable(host, result.result) self.callbacks.on_unreachable(host, result.result)
else: else:
data = result.result data = result.result
result.result['item'] = inject.get('item', None)
if 'skipped' in data: if 'skipped' in data:
self.callbacks.on_skipped(result.host) self.callbacks.on_skipped(result.host)
elif not result.is_successful(): elif not result.is_successful():