better display for free strategy (#17355)
This commit is contained in:
parent
e326da28ff
commit
7450629733
1 changed files with 32 additions and 1 deletions
|
@ -34,7 +34,17 @@ class CallbackModule(CallbackBase):
|
||||||
CALLBACK_TYPE = 'stdout'
|
CALLBACK_TYPE = 'stdout'
|
||||||
CALLBACK_NAME = 'default'
|
CALLBACK_NAME = 'default'
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
self._play = None
|
||||||
|
self._last_task_banner = None
|
||||||
|
super(CallbackModule, self).__init__()
|
||||||
|
|
||||||
def v2_runner_on_failed(self, result, ignore_errors=False):
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
||||||
|
|
||||||
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
||||||
|
self._print_task_banner(result._task)
|
||||||
|
|
||||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||||
if 'exception' in result._result:
|
if 'exception' in result._result:
|
||||||
if self._display.verbosity < 3:
|
if self._display.verbosity < 3:
|
||||||
|
@ -60,6 +70,11 @@ class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
def v2_runner_on_ok(self, result):
|
def v2_runner_on_ok(self, result):
|
||||||
|
|
||||||
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
||||||
|
self._print_task_banner(result._task)
|
||||||
|
|
||||||
|
self._clean_results(result._result, result._task.action)
|
||||||
|
|
||||||
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 result._task.action in ('include', 'include_role'):
|
if result._task.action in ('include', 'include_role'):
|
||||||
|
@ -89,6 +104,9 @@ class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
def v2_runner_on_skipped(self, result):
|
def v2_runner_on_skipped(self, result):
|
||||||
if C.DISPLAY_SKIPPED_HOSTS:
|
if C.DISPLAY_SKIPPED_HOSTS:
|
||||||
|
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
|
||||||
|
self._print_task_banner(result._task)
|
||||||
|
|
||||||
if result._task.loop and 'results' in result._result:
|
if result._task.loop and 'results' in result._result:
|
||||||
self._process_items(result)
|
self._process_items(result)
|
||||||
else:
|
else:
|
||||||
|
@ -98,6 +116,9 @@ 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:
|
||||||
|
self._print_task_banner(result._task)
|
||||||
|
|
||||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||||
if delegated_vars:
|
if delegated_vars:
|
||||||
self._display.display("fatal: [%s -> %s]: UNREACHABLE! => %s" % (result._host.get_name(), delegated_vars['ansible_host'], self._dump_results(result._result)), color=C.COLOR_UNREACHABLE)
|
self._display.display("fatal: [%s -> %s]: UNREACHABLE! => %s" % (result._host.get_name(), delegated_vars['ansible_host'], self._dump_results(result._result)), color=C.COLOR_UNREACHABLE)
|
||||||
|
@ -111,7 +132,11 @@ 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):
|
||||||
args = ''
|
|
||||||
|
if self._play.strategy != 'free':
|
||||||
|
self._print_task_banner(task)
|
||||||
|
|
||||||
|
def _print_task_banner(self, task):
|
||||||
# args can be specified as no_log in several places: in the task or in
|
# args can be specified as no_log in several places: in the task or in
|
||||||
# the argument spec. We can check whether the task is no_log but the
|
# the argument spec. We can check whether the task is no_log but the
|
||||||
# argument spec can't be because that is only run on the target
|
# argument spec can't be because that is only run on the target
|
||||||
|
@ -120,15 +145,19 @@ class CallbackModule(CallbackBase):
|
||||||
# So we give people a config option to affect display of the args so
|
# So we give people a config option to affect display of the args so
|
||||||
# that they can secure this if they feel that their stdout is insecure
|
# that they can secure this if they feel that their stdout is insecure
|
||||||
# (shoulder surfing, logging stdout straight to a file, etc).
|
# (shoulder surfing, logging stdout straight to a file, etc).
|
||||||
|
args = ''
|
||||||
if not task.no_log and C.DISPLAY_ARGS_TO_STDOUT:
|
if not task.no_log and C.DISPLAY_ARGS_TO_STDOUT:
|
||||||
args = ', '.join(('%s=%s' % a for a in task.args.items()))
|
args = ', '.join(('%s=%s' % a for a in task.args.items()))
|
||||||
args = ' %s' % args
|
args = ' %s' % args
|
||||||
|
|
||||||
self._display.banner("TASK [%s%s]" % (task.get_name().strip(), args))
|
self._display.banner("TASK [%s%s]" % (task.get_name().strip(), args))
|
||||||
if self._display.verbosity >= 2:
|
if self._display.verbosity >= 2:
|
||||||
path = task.get_path()
|
path = task.get_path()
|
||||||
if path:
|
if path:
|
||||||
self._display.display("task path: %s" % path, color=C.COLOR_DEBUG)
|
self._display.display("task path: %s" % path, color=C.COLOR_DEBUG)
|
||||||
|
|
||||||
|
self._last_task_banner = task._uuid
|
||||||
|
|
||||||
def v2_playbook_on_cleanup_task_start(self, task):
|
def v2_playbook_on_cleanup_task_start(self, task):
|
||||||
self._display.banner("CLEANUP TASK [%s]" % task.get_name().strip())
|
self._display.banner("CLEANUP TASK [%s]" % task.get_name().strip())
|
||||||
|
|
||||||
|
@ -142,6 +171,8 @@ class CallbackModule(CallbackBase):
|
||||||
else:
|
else:
|
||||||
msg = "PLAY [%s]" % name
|
msg = "PLAY [%s]" % name
|
||||||
|
|
||||||
|
self._play = play
|
||||||
|
|
||||||
self._display.banner(msg)
|
self._display.banner(msg)
|
||||||
|
|
||||||
def v2_on_file_diff(self, result):
|
def v2_on_file_diff(self, result):
|
||||||
|
|
Loading…
Reference in a new issue