Added docstrings to V2 methods in the CallbackBase Class (4 & 5 of 27) (#83507)

* Added docstrings to V2 methods in the CallbackBase Class (4 & 5 of 27)

* Made corrections as requested by webknjaz.

* Cleaned up whitespace issues.

* Corrections to customization note for review by webknjaz.

* Added rtype to return in docstrings.

* Simplified docstrings.


Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
pull/84504/head
Rob Garcia 11 months ago committed by GitHub
parent cae4f90b21
commit db44fc58ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -506,67 +506,91 @@ class CallbackBase(AnsiblePlugin):
self.on_any(args, kwargs) self.on_any(args, kwargs)
def v2_runner_on_failed(self, result: TaskResult, ignore_errors: bool = False) -> None: def v2_runner_on_failed(self, result: TaskResult, ignore_errors: bool = False) -> None:
"""Get details about a failed task and whether or not Ansible should continue """Process results of a failed task.
running tasks on the host where the failure occurred, then process the details
as required by the callback (output, profiling, logging, notifications, etc.)
Note: The 'ignore_errors' directive only works when the task can run and returns Note: The value of 'ignore_errors' tells Ansible whether to
a value of 'failed'. It does not make Ansible ignore undefined variable errors, continue running tasks on the host where this task failed.
connection failures, execution issues (for example, missing packages), or syntax errors. But the 'ignore_errors' directive only works when the task can
run and returns a value of 'failed'. It does not make Ansible
ignore undefined variable errors, connection failures, execution
issues (for example, missing packages), or syntax errors.
Customization note: For more information about the attributes and methods of the :param result: The parameters of the task and its results.
TaskResult class, see lib/ansible/executor/task_result.py. :type result: TaskResult
:param ignore_errors: Whether Ansible should continue \
:param TaskResult result: An object that contains details about the task running tasks on the host where the task failed.
:param bool ignore_errors: Whether or not Ansible should continue running tasks on the host :type ignore_errors: bool
where the failure occurred
:return: None :return: None
:rtype: 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)
def v2_runner_on_ok(self, result: TaskResult) -> None: def v2_runner_on_ok(self, result: TaskResult) -> None:
"""Get details about a successful task and process them as required by the callback """Process results of a successful task.
(output, profiling, logging, notifications, etc.)
Customization note: For more information about the attributes and methods of the
TaskResult class, see lib/ansible/executor/task_result.py.
:param TaskResult result: An object that contains details about the task :param result: The parameters of the task and its results.
:type result: TaskResult
:return: None :return: None
:rtype: None
""" """
host = result._host.get_name() host = result._host.get_name()
self.runner_on_ok(host, result._result) self.runner_on_ok(host, result._result)
def v2_runner_on_skipped(self, result: TaskResult) -> None: def v2_runner_on_skipped(self, result: TaskResult) -> None:
"""Get details about a skipped task and process them as required by the callback """Process results of a skipped task.
(output, profiling, logging, notifications, etc.)
Customization note: For more information about the attributes and methods of the :param result: The parameters of the task and its results.
TaskResult class, see lib/ansible/executor/task_result.py. :type result: TaskResult
:param TaskResult result: An object that contains details about the task
:return: None :return: None
:rtype: None
""" """
if C.DISPLAY_SKIPPED_HOSTS: if C.DISPLAY_SKIPPED_HOSTS:
host = result._host.get_name() host = result._host.get_name()
self.runner_on_skipped(host, self._get_item_label(getattr(result._result, 'results', {}))) self.runner_on_skipped(host, self._get_item_label(getattr(result._result, 'results', {})))
def v2_runner_on_unreachable(self, result): def v2_runner_on_unreachable(self, result: TaskResult) -> None:
"""Process results of a task if a target node is unreachable.
:param result: The parameters of the task and its results.
:type result: TaskResult
:return: None
:rtype: None
"""
host = result._host.get_name() host = result._host.get_name()
self.runner_on_unreachable(host, result._result) self.runner_on_unreachable(host, result._result)
def v2_runner_on_async_poll(self, result): def v2_runner_on_async_poll(self, result: TaskResult) -> None:
"""Get details about an unfinished task running in async mode.
Note: The value of the `poll` keyword in the task determines
the interval at which polling occurs and this method is run.
:param result: The parameters of the task and its status.
:type result: TaskResult
:rtype: None
:rtype: None
"""
host = result._host.get_name() host = result._host.get_name()
jid = result._result.get('ansible_job_id') jid = result._result.get('ansible_job_id')
# FIXME, get real clock # FIXME, get real clock
clock = 0 clock = 0
self.runner_on_async_poll(host, result._result, jid, clock) self.runner_on_async_poll(host, result._result, jid, clock)
def v2_runner_on_async_ok(self, result): def v2_runner_on_async_ok(self, result: TaskResult) -> None:
"""Process results of a successful task that ran in async mode.
:param result: The parameters of the task and its results.
:type result: TaskResult
:return: None
:rtype: None
"""
host = result._host.get_name() host = result._host.get_name()
jid = result._result.get('ansible_job_id') jid = result._result.get('ansible_job_id')
self.runner_on_async_ok(host, result._result, jid) self.runner_on_async_ok(host, result._result, jid)

Loading…
Cancel
Save