Skip to content

Commit

Permalink
Only apply the unroll wrapper once (#72003) (#72017)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Martz <matt@sivel.net>

Fixes #71920

(cherry picked from commit 4197666)
  • Loading branch information
mkrizek committed Oct 21, 2020
1 parent cd89aad commit d53d247
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/71920-fix-templating-recursion-error.yml
@@ -0,0 +1,2 @@
bugfixes:
- Fix ``RecursionError`` when templating large vars structures (https://github.com/ansible/ansible/issues/71920)
4 changes: 3 additions & 1 deletion lib/ansible/template/__init__.py
Expand Up @@ -257,6 +257,7 @@ def wrapper(*args, **kwargs):
return list(ret)
return ret

wrapper.__UNROLLED__ = True
return _update_wrapper(wrapper, func)


Expand Down Expand Up @@ -1025,7 +1026,8 @@ def do_template(self, data, preserve_trailing_newlines=True, escape_backslashes=
# Adds Ansible custom filters and tests
myenv.filters.update(self._get_filters())
for k in myenv.filters:
myenv.filters[k] = _unroll_iterator(myenv.filters[k])
if not getattr(myenv.filters[k], '__UNROLLED__', False):
myenv.filters[k] = _unroll_iterator(myenv.filters[k])
myenv.tests.update(self._get_tests())

if escape_backslashes:
Expand Down

0 comments on commit d53d247

Please sign in to comment.