From 24f6a44a0cc6095b6d8f05a75500c6f6abcc5514 Mon Sep 17 00:00:00 2001 From: Kaitlin Seng Date: Thu, 8 Jul 2021 14:13:48 -0400 Subject: [PATCH] Display tasks times after a task completes, rather than at the beginning of the next task --- plugins/callback/profile_tasks.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/callback/profile_tasks.py b/plugins/callback/profile_tasks.py index 6edb325..d3478a9 100644 --- a/plugins/callback/profile_tasks.py +++ b/plugins/callback/profile_tasks.py @@ -9,6 +9,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +from ansible import constants as C + DOCUMENTATION = ''' callback: profile_tasks type: aggregate @@ -147,7 +149,6 @@ class CallbackModule(CallbackBase): """ Logs the start of each task """ - self._display.display(tasktime()) timestamp(self) # Record the start time of the current task @@ -156,6 +157,28 @@ class CallbackModule(CallbackBase): if self._display.verbosity >= 2: self.stats[self.current]['path'] = task.get_path() + def v2_runner_on_failed(self, result, ignore_errors=False): + self._display.display(tasktime()) + + def v2_runner_on_ok(self, result): + self._display.display(tasktime()) + + def v2_runner_on_skipped(self, result): + if C.DISPLAY_SKIPPED_HOSTS: + self._display.display(tasktime()) + + def v2_runner_on_unreachable(self, result): + self._display.display(tasktime()) + + def v2_runner_on_async_poll(self, result): + self._display.display(tasktime()) + + def v2_runner_on_async_ok(self, result): + self._display.display(tasktime()) + + def v2_runner_on_async_failed(self, result): + self._display.display(tasktime()) + def v2_playbook_on_task_start(self, task, is_conditional): self._record_task(task)