hide uneeded fields for callbacks (#36259)
* hide uneeded fields for callbacks fix selective instead of pushing uneeded fields to the methods * piipii
This commit is contained in:
parent
c119d54e4a
commit
6af5693dc2
2 changed files with 14 additions and 10 deletions
|
@ -10,8 +10,8 @@ from copy import deepcopy
|
|||
from ansible.parsing.dataloader import DataLoader
|
||||
from ansible.vars.clean import strip_internal_keys
|
||||
|
||||
_IGNORE = tuple()
|
||||
_PRESERVE = ('attempts', 'changed', 'retries', 'failed', 'unreachable', 'skipped')
|
||||
_IGNORE = ('failed', 'skipped')
|
||||
_PRESERVE = ('attempts', 'changed', 'retries')
|
||||
|
||||
|
||||
class TaskResult:
|
||||
|
|
|
@ -178,13 +178,10 @@ class CallbackModule(CallbackBase):
|
|||
self.last_task_name = task.get_name()
|
||||
self.printed_last_task = False
|
||||
|
||||
def v2_runner_on_ok(self, result, **kwargs):
|
||||
def _print_task_result(self, result, error=False, **kwargs):
|
||||
"""Run when a task finishes correctly."""
|
||||
failed = result._result.get("failed")
|
||||
unreachable = result._result.get("unreachable")
|
||||
|
||||
if 'print_action' in result._task.tags or failed or unreachable or \
|
||||
self._display.verbosity > 1:
|
||||
if 'print_action' in result._task.tags or error or self._display.verbosity > 1:
|
||||
self._print_task()
|
||||
self.last_skipped = False
|
||||
msg = to_text(result._result.get('msg', '')) or\
|
||||
|
@ -199,7 +196,7 @@ class CallbackModule(CallbackBase):
|
|||
msg,
|
||||
result._result.get('diff', None),
|
||||
is_host=True,
|
||||
error=failed or unreachable,
|
||||
error=error,
|
||||
stdout=result._result.get('module_stdout', None),
|
||||
stderr=stderr.strip(),
|
||||
)
|
||||
|
@ -267,6 +264,13 @@ class CallbackModule(CallbackBase):
|
|||
print(self._indent_text(reason, 8))
|
||||
print(reason)
|
||||
|
||||
def v2_runner_on_ok(self, result, **kwargs):
|
||||
self._print_task_result(result, error=False, **kwargs)
|
||||
|
||||
def v2_runner_on_failed(self, result, **kwargs):
|
||||
self._print_task_result(result, error=True, **kwargs)
|
||||
|
||||
def v2_runner_on_unreachable(self, result, **kwargs):
|
||||
self._print_task_result(result, error=True, **kwargs)
|
||||
|
||||
v2_playbook_on_handler_task_start = v2_playbook_on_task_start
|
||||
v2_runner_on_failed = v2_runner_on_ok
|
||||
v2_runner_on_unreachable = v2_runner_on_ok
|
||||
|
|
Loading…
Reference in a new issue