Documented v2_runner_on_failed method in Callback class (#83267)

* Documented v2_runner_on_failed method in Callback class

* Added changes requested by @bcoca.
pull/83080/head
Rob Garcia 6 months ago committed by GitHub
parent 454dd9e91d
commit 347a822a42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -22,6 +22,7 @@ import json
import re import re
import sys import sys
import textwrap import textwrap
from typing import TYPE_CHECKING
from collections import OrderedDict from collections import OrderedDict
from collections.abc import MutableMapping from collections.abc import MutableMapping
@ -41,6 +42,9 @@ from ansible.vars.clean import strip_internal_keys, module_response_deepcopy
import yaml import yaml
if TYPE_CHECKING:
from ansible.executor.task_result import TaskResult
global_display = Display() global_display = Display()
@ -501,7 +505,20 @@ class CallbackBase(AnsiblePlugin):
def v2_on_any(self, *args, **kwargs): def v2_on_any(self, *args, **kwargs):
self.on_any(args, kwargs) self.on_any(args, kwargs)
def v2_runner_on_failed(self, result, ignore_errors=False): def v2_runner_on_failed(self, result: TaskResult, ignore_errors: bool = False) -> None:
"""Show result, output, and optional information, based on verbosity level, vars, and
ansible.cfg settings, if a task failed.
Customization notes - In this method:
- You can access TaskResult class methods and attributes like result.is_changed()
and result.task_name
- The ansible.executor.task_result.TaskResult class is defined in
lib/ansible/executor/task_result.py
:param TaskResult result: The result and output of a task
:param bool ignore_errors: The value of the ignore_errors vars
:return: None
"""
host = result._host.get_name() host = result._host.get_name()
self.runner_on_failed(host, result._result, ignore_errors) self.runner_on_failed(host, result._result, ignore_errors)

Loading…
Cancel
Save