Skip to content

Commit

Permalink
Only apply the unroll wrapper once (ansible#72003)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Martz <[email protected]>

Fixes ansible#71920
  • Loading branch information
mkrizek authored Sep 30, 2020
1 parent 8893a24 commit 4197666
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 @@ -1086,7 +1087,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 4197666

Please sign in to comment.