tests: make nice_stdout print failing task line number

pull/372/head
David Wilson 6 years ago
parent 897bc07ea0
commit 5bac246676

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import os
import io
from ansible import constants as C
from ansible.module_utils import six
try:
@ -65,3 +66,34 @@ class CallbackModule(DefaultModule):
import traceback
traceback.print_exc()
raise
def v2_runner_on_failed(self, result, ignore_errors=False):
delegated_vars = result._result.get('_ansible_delegated_vars')
self._clean_results(result._result, result._task.action)
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
self._print_task_banner(result._task)
self._handle_exception(result._result)
self._handle_warnings(result._result)
if result._task.loop and 'results' in result._result:
return
if delegated_vars:
msg = "[%s -> %s]: FAILED! => %s" % (
result._host.get_name(),
delegated_vars['ansible_host'],
self._dump_results(result._result),
)
else:
msg = "[%s]: FAILED! => %s" % (
result._host.get_name(),
self._dump_results(result._result),
)
s = "fatal: %s: %s" % (
result._task.get_path() or '(dynamic task)',
msg,
)
self._display.display(s, color=C.COLOR_ERROR)

Loading…
Cancel
Save