From 9bbaa0d6880ea26911d044e9ac47d03f6ebff6f6 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Wed, 18 Sep 2019 14:39:59 -0700 Subject: [PATCH] fix collection jinja2 cache issue (#62543) * prevents premature lookup (and potential KeyError) of Jinja filter/test function cache that's not fully populated (cherry picked from commit d0c7b42e58fbae1832eaed699865fdd2f27b07cc) --- changelogs/fragments/collection_jinja_cache_fix.yml | 2 ++ lib/ansible/template/__init__.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/collection_jinja_cache_fix.yml diff --git a/changelogs/fragments/collection_jinja_cache_fix.yml b/changelogs/fragments/collection_jinja_cache_fix.yml new file mode 100644 index 00000000000..0835e1e217f --- /dev/null +++ b/changelogs/fragments/collection_jinja_cache_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - collection loader - ensure Jinja function cache is fully-populated before lookup diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index ac79b4e588e..1503c82ea7e 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -350,12 +350,10 @@ class JinjaPluginIntercept(MutableMapping): for f in iteritems(method_map()): fq_name = '.'.join((parent_prefix, f[0])) + # FIXME: detect/warn on intra-collection function name collisions self._collection_jinja_func_cache[fq_name] = f[1] - function_impl = self._collection_jinja_func_cache[key] - - # FIXME: detect/warn on intra-collection function name collisions - + function_impl = self._collection_jinja_func_cache[key] return function_impl def __setitem__(self, key, value):