1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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:
Brian Coca 2018-02-20 08:41:18 -05:00 committed by GitHub
parent c119d54e4a
commit 6af5693dc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View file

@ -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:

View file

@ -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