From fd662c0a638bb482c434ba0f2a6593189b25078b Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 30 Oct 2018 11:37:11 -0500 Subject: [PATCH] New v2_runner_on_start callback added (#47684) * New v2_runner_on_start callback added to indicate the start of execution for a host in a specific task * Add changelog fragment * Minor docstring clarification --- changelogs/fragments/host-start-callback.yaml | 2 ++ lib/ansible/plugins/callback/__init__.py | 7 +++++++ lib/ansible/plugins/strategy/__init__.py | 1 + 3 files changed, 10 insertions(+) create mode 100644 changelogs/fragments/host-start-callback.yaml diff --git a/changelogs/fragments/host-start-callback.yaml b/changelogs/fragments/host-start-callback.yaml new file mode 100644 index 00000000000..fd0e1d49281 --- /dev/null +++ b/changelogs/fragments/host-start-callback.yaml @@ -0,0 +1,2 @@ +minor_changes: +- callbacks - New ``v2_runner_on_start`` callback added to indicate the start of execution for a host in a specific task (https://github.com/ansible/ansible/pull/47684) diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index 77282150150..3720e6f9934 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -412,3 +412,10 @@ class CallbackBase(AnsiblePlugin): def v2_runner_retry(self, result): pass + + def v2_runner_on_start(self, host, task): + """Event used when host begins execution of a task + + .. versionadded:: 2.8 + """ + pass diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index ae24eda7171..62c15d43d44 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -317,6 +317,7 @@ class StrategyBase: worker_prc = WorkerProcess(self._final_q, task_vars, host, task, play_context, self._loader, self._variable_manager, shared_loader_obj) self._workers[self._cur_worker] = worker_prc + self._tqm.send_callback('v2_runner_on_start', host, task) worker_prc.start() display.debug("worker is %d (out of %d available)" % (self._cur_worker + 1, len(self._workers))) queued = True