diff --git a/changelogs/fragments/free-strategy-include-var-tags.yaml b/changelogs/fragments/free-strategy-include-var-tags.yaml new file mode 100644 index 00000000000..b2b3665d137 --- /dev/null +++ b/changelogs/fragments/free-strategy-include-var-tags.yaml @@ -0,0 +1,2 @@ +bugfixes: +- dynamic includes - Use the copied and merged task for calculating task vars in the free strategy (https://github.com/ansible/ansible/issues/47024) diff --git a/lib/ansible/plugins/strategy/free.py b/lib/ansible/plugins/strategy/free.py index 207f63207be..f83e38cb63a 100644 --- a/lib/ansible/plugins/strategy/free.py +++ b/lib/ansible/plugins/strategy/free.py @@ -237,7 +237,7 @@ class StrategyModule(StrategyBase): continue for new_block in new_blocks: - task_vars = self._variable_manager.get_vars(play=iterator._play, task=included_file._task) + task_vars = self._variable_manager.get_vars(play=iterator._play, task=new_block._parent) final_block = new_block.filter_tagged_tasks(play_context, task_vars) for host in hosts_left: if host in included_file._hosts: