diff options
author | Matt Martz <matt@sivel.net> | 2018-08-30 12:02:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 12:02:43 -0500 |
commit | 9d89e15ff0f6c7e6fd8022987d24d61e8dc40b57 (patch) | |
tree | fd02886ccb1e04d66dbf1c210b2a624b4b8c2dff /lib/ansible/vars | |
parent | 6059da245bd64fabace3f862f4e15d9a7dee5885 (diff) | |
download | ansible-9d89e15ff0f6c7e6fd8022987d24d61e8dc40b57.tar.gz |
Ensure we only cache the loop when the task had a loop (#44901)
* Further restrict caching of loop when the task actually had a loop. Fixes #44874
* Extend tests for loop caching
Diffstat (limited to 'lib/ansible/vars')
-rw-r--r-- | lib/ansible/vars/manager.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 7ac85f5a25..ebbfa6aedc 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -494,6 +494,7 @@ class VariableManager: templar = Templar(loader=self._loader, variables=vars_copy) items = [] + has_loop = True if task.loop_with is not None: if task.loop_with in lookup_loader: try: @@ -509,6 +510,7 @@ class VariableManager: elif task.loop is not None: items = templar.template(task.loop) else: + has_loop = False items = [None] delegated_host_vars = dict() @@ -583,7 +585,7 @@ class VariableManager: include_hostvars=False, ) - if cache_items: + if has_loop and cache_items: # delegate_to templating produced a change, update task.loop with templated items, # this ensures that delegate_to+loop doesn't produce different results than TaskExecutor # which may reprocess the loop |