Explicitly get the include task, and not assume it is the parent (#72378)
* Explicitly get the include task, and not assume it is the parent. Fixes #6571
This commit is contained in:
parent
a51a6f4a25
commit
e73a0b2460
5 changed files with 19 additions and 2 deletions
3
changelogs/fragments/65710-find-include-parent.yml
Normal file
3
changelogs/fragments/65710-find-include-parent.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- Includes - Explicitly get the include task, and not assume it is the parent
|
||||||
|
(https://github.com/ansible/ansible/issues/65710)
|
|
@ -259,7 +259,7 @@ class StrategyModule(StrategyBase):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for new_block in new_blocks:
|
for new_block in new_blocks:
|
||||||
task_vars = self._variable_manager.get_vars(play=iterator._play, task=new_block._parent,
|
task_vars = self._variable_manager.get_vars(play=iterator._play, task=new_block.get_first_parent_include(),
|
||||||
_hosts=self._hosts_cache,
|
_hosts=self._hosts_cache,
|
||||||
_hosts_all=self._hosts_cache_all)
|
_hosts_all=self._hosts_cache_all)
|
||||||
final_block = new_block.filter_tagged_tasks(task_vars)
|
final_block = new_block.filter_tagged_tasks(task_vars)
|
||||||
|
|
|
@ -366,7 +366,7 @@ class StrategyModule(StrategyBase):
|
||||||
for new_block in new_blocks:
|
for new_block in new_blocks:
|
||||||
task_vars = self._variable_manager.get_vars(
|
task_vars = self._variable_manager.get_vars(
|
||||||
play=iterator._play,
|
play=iterator._play,
|
||||||
task=new_block._parent,
|
task=new_block.get_first_parent_include(),
|
||||||
_hosts=self._hosts_cache,
|
_hosts=self._hosts_cache,
|
||||||
_hosts_all=self._hosts_cache_all,
|
_hosts_all=self._hosts_cache_all,
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- include_tasks:
|
||||||
|
file: include_tasks.yml
|
||||||
|
apply:
|
||||||
|
tags: always
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- include_tasks_result is defined
|
|
@ -81,6 +81,9 @@ if [[ -z "$OUT" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ANSIBLE_STRATEGY='linear' ANSIBLE_PLAYBOOK_VARS_ROOT=all ansible-playbook apply/include_apply_65710.yml -i inventory "$@"
|
||||||
|
ANSIBLE_STRATEGY='free' ANSIBLE_PLAYBOOK_VARS_ROOT=all ansible-playbook apply/include_apply_65710.yml -i inventory "$@"
|
||||||
|
|
||||||
# Test that duplicate items in loop are not deduped
|
# Test that duplicate items in loop are not deduped
|
||||||
ANSIBLE_STRATEGY='linear' ansible-playbook tasks/test_include_dupe_loop.yml -i inventory "$@" | tee test_include_dupe_loop.out
|
ANSIBLE_STRATEGY='linear' ansible-playbook tasks/test_include_dupe_loop.yml -i inventory "$@" | tee test_include_dupe_loop.out
|
||||||
test "$(grep -c '"item=foo"' test_include_dupe_loop.out)" = 3
|
test "$(grep -c '"item=foo"' test_include_dupe_loop.out)" = 3
|
||||||
|
|
Loading…
Add table
Reference in a new issue