From c63189f6500ab37523ab883f287084c9a73bda76 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 25 Sep 2012 20:36:13 -0400 Subject: [PATCH] Make output be cleaner on multi-line failed commands and parse errors. --- lib/ansible/callbacks.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py index 60ad02af73b..cbde540309b 100644 --- a/lib/ansible/callbacks.py +++ b/lib/ansible/callbacks.py @@ -296,11 +296,25 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): results2.pop('invocation', None) item = results2.get('item', None) + parsed = results2.get('parsed', True) + module_msg = '' + if not parsed: + module_msg = results2.pop('msg', None) + stderr = results2.pop('stderr', None) + stdout = results2.pop('stdout', None) + if item: msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results2)) else: msg = "failed: [%s] => %s" % (host, utils.jsonify(results2)) print stringc(msg, 'red') + + if stderr: + print stringc("stderr: %s" % stderr, 'red') + if stdout: + print stringc("stdout: %s" % stdout, 'red') + if not parsed and module_msg: + print stringc("invalid output was: %s" % module_msg, 'red') if ignore_errors: print stringc("...ignoring", 'yellow') super(PlaybookRunnerCallbacks, self).on_failed(host, results, ignore_errors=ignore_errors)