|
|
@ -39,6 +39,7 @@ class CallbackModule(CallbackBase):
|
|
|
|
|
|
|
|
|
|
|
|
self._play = None
|
|
|
|
self._play = None
|
|
|
|
self._last_task_banner = None
|
|
|
|
self._last_task_banner = None
|
|
|
|
|
|
|
|
self._last_task_name = None
|
|
|
|
super(CallbackModule, self).__init__()
|
|
|
|
super(CallbackModule, self).__init__()
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
|
|
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
|
|
@ -46,10 +47,12 @@ class CallbackModule(CallbackBase):
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
|
|
|
|
|
|
|
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
|
|
|
if self._last_task_banner != result._task._uuid:
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
|
|
|
|
|
|
|
|
self._handle_exception(result._result)
|
|
|
|
use_stderr = self._plugin_options.get('display_failed_stderr', False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._handle_exception(result._result, use_stderr=use_stderr)
|
|
|
|
self._handle_warnings(result._result)
|
|
|
|
self._handle_warnings(result._result)
|
|
|
|
|
|
|
|
|
|
|
|
if result._task.loop and 'results' in result._result:
|
|
|
|
if result._task.loop and 'results' in result._result:
|
|
|
@ -58,18 +61,22 @@ class CallbackModule(CallbackBase):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if delegated_vars:
|
|
|
|
if delegated_vars:
|
|
|
|
self._display.display("fatal: [%s -> %s]: FAILED! => %s" % (result._host.get_name(), delegated_vars['ansible_host'],
|
|
|
|
self._display.display("fatal: [%s -> %s]: FAILED! => %s" % (result._host.get_name(), delegated_vars['ansible_host'],
|
|
|
|
self._dump_results(result._result)), color=C.COLOR_ERROR)
|
|
|
|
self._dump_results(result._result)),
|
|
|
|
|
|
|
|
color=C.COLOR_ERROR, stderr=use_stderr)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self._display.display("fatal: [%s]: FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result)), color=C.COLOR_ERROR)
|
|
|
|
self._display.display("fatal: [%s]: FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result)),
|
|
|
|
|
|
|
|
color=C.COLOR_ERROR, stderr=use_stderr)
|
|
|
|
|
|
|
|
|
|
|
|
if ignore_errors:
|
|
|
|
if ignore_errors:
|
|
|
|
self._display.display("...ignoring", color=C.COLOR_SKIP)
|
|
|
|
self._display.display("...ignoring", color=C.COLOR_SKIP)
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_on_ok(self, result):
|
|
|
|
def v2_runner_on_ok(self, result):
|
|
|
|
|
|
|
|
if not self._plugin_options.get('display_ok_hosts'):
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
|
|
|
|
|
|
|
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
|
|
|
if self._last_task_banner != result._task._uuid:
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
|
|
|
|
|
|
|
|
if isinstance(result._task, TaskInclude):
|
|
|
|
if isinstance(result._task, TaskInclude):
|
|
|
@ -99,11 +106,11 @@ class CallbackModule(CallbackBase):
|
|
|
|
self._display.display(msg, color=color)
|
|
|
|
self._display.display(msg, color=color)
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_on_skipped(self, result):
|
|
|
|
def v2_runner_on_skipped(self, result):
|
|
|
|
if self._plugin_options.get('show_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
|
|
|
|
if self._plugin_options.get('display_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
|
|
|
|
|
|
|
|
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
|
|
|
|
|
|
|
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
|
|
|
if self._last_task_banner != result._task._uuid:
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
|
|
|
|
|
|
|
|
if result._task.loop and 'results' in result._result:
|
|
|
|
if result._task.loop and 'results' in result._result:
|
|
|
@ -115,7 +122,7 @@ class CallbackModule(CallbackBase):
|
|
|
|
self._display.display(msg, color=C.COLOR_SKIP)
|
|
|
|
self._display.display(msg, color=C.COLOR_SKIP)
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_on_unreachable(self, result):
|
|
|
|
def v2_runner_on_unreachable(self, result):
|
|
|
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
|
|
|
if self._last_task_banner != result._task._uuid:
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
self._print_task_banner(result._task)
|
|
|
|
|
|
|
|
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
@ -133,8 +140,13 @@ class CallbackModule(CallbackBase):
|
|
|
|
self._display.banner("NO MORE HOSTS LEFT")
|
|
|
|
self._display.banner("NO MORE HOSTS LEFT")
|
|
|
|
|
|
|
|
|
|
|
|
def v2_playbook_on_task_start(self, task, is_conditional):
|
|
|
|
def v2_playbook_on_task_start(self, task, is_conditional):
|
|
|
|
|
|
|
|
# Preserve task name, as all vars may not be available for templating
|
|
|
|
|
|
|
|
# when we need it later
|
|
|
|
if self._play.strategy != 'free':
|
|
|
|
if self._play.strategy != 'free':
|
|
|
|
|
|
|
|
self._last_task_name = task.get_name().strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Display the task banner immediately if we're not doing any filtering based on task result
|
|
|
|
|
|
|
|
if self._plugin_options.get('display_skipped_hosts') and self._plugin_options.get('display_ok_hosts'):
|
|
|
|
self._print_task_banner(task)
|
|
|
|
self._print_task_banner(task)
|
|
|
|
|
|
|
|
|
|
|
|
def _print_task_banner(self, task):
|
|
|
|
def _print_task_banner(self, task):
|
|
|
@ -151,7 +163,12 @@ class CallbackModule(CallbackBase):
|
|
|
|
args = u', '.join(u'%s=%s' % a for a in task.args.items())
|
|
|
|
args = u', '.join(u'%s=%s' % a for a in task.args.items())
|
|
|
|
args = u' %s' % args
|
|
|
|
args = u' %s' % args
|
|
|
|
|
|
|
|
|
|
|
|
self._display.banner(u"TASK [%s%s]" % (task.get_name().strip(), args))
|
|
|
|
# Use cached task name
|
|
|
|
|
|
|
|
task_name = self._last_task_name
|
|
|
|
|
|
|
|
if task_name is None:
|
|
|
|
|
|
|
|
task_name = task.get_name().strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._display.banner(u"TASK [%s%s]" % (task_name, args))
|
|
|
|
if self._display.verbosity >= 2:
|
|
|
|
if self._display.verbosity >= 2:
|
|
|
|
path = task.get_path()
|
|
|
|
path = task.get_path()
|
|
|
|
if path:
|
|
|
|
if path:
|
|
|
@ -189,6 +206,9 @@ class CallbackModule(CallbackBase):
|
|
|
|
self._display.display(diff)
|
|
|
|
self._display.display(diff)
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_item_on_ok(self, result):
|
|
|
|
def v2_runner_item_on_ok(self, result):
|
|
|
|
|
|
|
|
if not self._plugin_options.get('display_ok_hosts'):
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
if isinstance(result._task, TaskInclude):
|
|
|
|
if isinstance(result._task, TaskInclude):
|
|
|
@ -227,7 +247,7 @@ class CallbackModule(CallbackBase):
|
|
|
|
self._display.display(msg + " (item=%s) => %s" % (self._get_item_label(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR)
|
|
|
|
self._display.display(msg + " (item=%s) => %s" % (self._get_item_label(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR)
|
|
|
|
|
|
|
|
|
|
|
|
def v2_runner_item_on_skipped(self, result):
|
|
|
|
def v2_runner_item_on_skipped(self, result):
|
|
|
|
if self._plugin_options.get('show_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
|
|
|
|
if self._plugin_options.get('display_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
self._clean_results(result._result, result._task.action)
|
|
|
|
msg = "skipping: [%s] => (item=%s) " % (result._host.get_name(), self._get_item_label(result._result))
|
|
|
|
msg = "skipping: [%s] => (item=%s) " % (result._host.get_name(), self._get_item_label(result._result))
|
|
|
|
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
|
|
|
|
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
|
|
|
|