mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Don't use the task for a cache, return a special cache var (#47243)
* Don't use task to cache loop results, use hostvars. Fixes #47207 * Avoid a race condition, supply _ansible_loop_cache through get_vars directly * Add tests * Add changelog fragment * Remove unnecessary copy * Remove unnecessary host from _get_delegated_vars signature
This commit is contained in:
parent
9e2c02455a
commit
77d32b8f57
5 changed files with 63 additions and 10 deletions
|
@ -210,7 +210,12 @@ class TaskExecutor:
|
|||
|
||||
templar = Templar(loader=self._loader, shared_loader_obj=self._shared_loader_obj, variables=self._job_vars)
|
||||
items = None
|
||||
if self._task.loop_with:
|
||||
loop_cache = self._job_vars.get('_ansible_loop_cache')
|
||||
if loop_cache is not None:
|
||||
# _ansible_loop_cache may be set in `get_vars` when calculating `delegate_to`
|
||||
# to avoid reprocessing the loop
|
||||
items = loop_cache
|
||||
elif self._task.loop_with:
|
||||
if self._task.loop_with in self._shared_loader_obj.lookup_loader:
|
||||
fail = True
|
||||
if self._task.loop_with == 'first_found':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue