From 7bf56ceee39bbc8f2c3f01bc45b7a151bc54bcdc Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 17 Feb 2017 00:07:21 -0600 Subject: [PATCH] Relocate creation of Templar in process_pending_results Moving it to after the blocks where per-item results are calculated, as it's not used there and causes quite a performance hit being there. Fixes #21340 --- lib/ansible/plugins/strategy/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 9252b6c4474..a4204577e90 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -332,11 +332,6 @@ class StrategyBase: else: loop_var = 'item' - # get the vars for this task/host pair, make them the active set of vars for our templar above - task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=original_host, task=original_task) - self.add_tqm_variables(task_vars, play=iterator._play) - templar.set_available_variables(task_vars) - # send callbacks for 'non final' results if '_ansible_retry' in task_result._result: self._tqm.send_callback('v2_runner_retry', task_result) @@ -353,6 +348,11 @@ class StrategyBase: self._tqm.send_callback('v2_runner_item_on_ok', task_result) continue + # get the vars for this task/host pair, make them the active set of vars for our templar above + task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=original_host, task=original_task) + self.add_tqm_variables(task_vars, play=iterator._play) + templar.set_available_variables(task_vars) + run_once = templar.template(original_task.run_once) if original_task.register: host_list = self.get_task_hosts(iterator, original_host, original_task)