mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07: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:
parent
9f9bfd819f
commit
63fdc3f08f
5 changed files with 52 additions and 22 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue