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

Pretty-print "msg" when task fails

Several modules (e.g., pip) return stdout and stderr together in a "msg" variable (and the module development docs seem to suggest that the standard practice is to return status in this variable).

This change ensures that it is printed out with correct formatting (most importantly, with newlines appearing as newlines instead of \n).
This commit is contained in:
Lorin Hochstein 2012-11-01 13:22:34 -04:00
parent 4399d9c3cb
commit 1c5ac5cac8

View file

@ -314,6 +314,7 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
module_msg = results2.pop('msg', None) module_msg = results2.pop('msg', None)
stderr = results2.pop('stderr', None) stderr = results2.pop('stderr', None)
stdout = results2.pop('stdout', None) stdout = results2.pop('stdout', None)
returned_msg = results2.pop('msg', None)
if item: if item:
msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results2)) msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results2))
@ -325,6 +326,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
print stringc("stderr: %s" % stderr, 'red') print stringc("stderr: %s" % stderr, 'red')
if stdout: if stdout:
print stringc("stdout: %s" % stdout, 'red') print stringc("stdout: %s" % stdout, 'red')
if returned_msg:
print stringc("msg: %s" % returned_msg, 'red')
if not parsed and module_msg: if not parsed and module_msg:
print stringc("invalid output was: %s" % module_msg, 'red') print stringc("invalid output was: %s" % module_msg, 'red')
if ignore_errors: if ignore_errors: