Templating: make sure only one variable results are cached (#67429)

* Make sure only one variable results are cached.

* Add changelog.

* Add test.

(cherry picked from commit c520d70bf4)
pull/67619/head
Felix Fontein 5 years ago committed by Matt Clay
parent 48bfa3e906
commit b38603c45e

@ -0,0 +1,2 @@
bugfixes:
- "Templating - Ansible was caching results of Jinja2 expressions in some cases where these expressions could have dynamic results, like password generation (https://github.com/ansible/ansible/issues/34144)."

@ -596,7 +596,7 @@ class Templar:
# we only cache in the case where we have a single variable
# name, to make sure we're not putting things which may otherwise
# be dynamic in the cache (filters, lookups, etc.)
if cache:
if cache and only_one:
self._cached_result[sha1_hash] = result
return result

Loading…
Cancel
Save