diff --git a/changelogs/fragments/includes.yaml b/changelogs/fragments/includes.yaml index 62eaf0f2062..a1e9aed2bd2 100644 --- a/changelogs/fragments/includes.yaml +++ b/changelogs/fragments/includes.yaml @@ -14,3 +14,4 @@ bugfixes: - dynamic includes - Allow inheriting attributes from static parents (https://github.com/ansible/ansible/pull/38827) - include_role/import_role - improved performance and recursion depth (https://github.com/ansible/ansible/pull/36470) - include_role/import_role - Fix parameter templating (https://github.com/ansible/ansible/pull/36372) +- dynamic includes - Use the copied and merged task for calculating task vars (https://github.com/ansible/ansible/pull/39762) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index ff51b7d35cd..4de191a5ad8 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -363,7 +363,7 @@ class StrategyModule(StrategyBase): for new_block in new_blocks: task_vars = self._variable_manager.get_vars( play=iterator._play, - task=included_file._task, + task=new_block._parent ) display.debug("filtering new block on tags") final_block = new_block.filter_tagged_tasks(play_context, task_vars)