Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty-print "msg" when task fails #1507

Merged
merged 1 commit into from
Nov 1, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/ansible/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def load_more_callbacks(dirname):
def call_callback_module(method_name, *args, **kwargs):

for callback_plugin in callbacks:
methods = [
getattr(callback_plugin, method_name, None),
methods = [
getattr(callback_plugin, method_name, None),
getattr(callback_plugin, 'on_any', None)
]
for method in methods:
Expand Down Expand Up @@ -314,6 +314,7 @@ def on_failed(self, host, results, ignore_errors=False):
module_msg = results2.pop('msg', None)
stderr = results2.pop('stderr', None)
stdout = results2.pop('stdout', None)
returned_msg = results2.pop('msg', None)

if item:
msg = "failed: [%s] => (item=%s) => %s" % (host, item, utils.jsonify(results2))
Expand All @@ -325,6 +326,8 @@ def on_failed(self, host, results, ignore_errors=False):
print stringc("stderr: %s" % stderr, 'red')
if stdout:
print stringc("stdout: %s" % stdout, 'red')
if returned_msg:
print stringc("msg: %s" % returned_msg, 'red')
if not parsed and module_msg:
print stringc("invalid output was: %s" % module_msg, 'red')
if ignore_errors:
Expand Down Expand Up @@ -457,7 +460,7 @@ def prompt(prompt, private):
while True:
result = prompt(msg, private)
second = prompt("confirm " + msg, private)
if result == second:
if result == second:
break
print "***** VALUES ENTERED DO NOT MATCH ****"
else:
Expand Down