mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Fix jinja2>=2.9 nested include vars (#35099)
This fixes a bug when parent's local vars where not available in nested includes. The bug can only be seen with jinja>=2.9 which changes how the variable scopes work. Fixes #34886
This commit is contained in:
@@ -121,4 +121,11 @@ class AnsibleJ2Vars(Mapping):
|
||||
'''
|
||||
if locals is None:
|
||||
return self
|
||||
return AnsibleJ2Vars(self._templar, self._globals, locals=locals, *self._extras)
|
||||
|
||||
# FIXME run this only on jinja2>=2.9?
|
||||
# prior to version 2.9, locals contained all of the vars and not just the current
|
||||
# local vars so this was not necessary for locals to propagate down to nested includes
|
||||
new_locals = self._locals.copy()
|
||||
new_locals.update(locals)
|
||||
|
||||
return AnsibleJ2Vars(self._templar, self._globals, locals=new_locals, *self._extras)
|
||||
|
||||
Reference in New Issue
Block a user