1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Don't template 'vars' dictionary during templating

Fixes #9132
This commit is contained in:
James Cammarata 2014-09-25 14:46:16 -05:00
parent 19703617b8
commit 128c10b311

View file

@ -166,6 +166,7 @@ class _jinja2_vars(object):
return False
def __getitem__(self, varname):
from ansible.runner import HostVars
if varname not in self.vars:
for i in self.extras:
if varname in i:
@ -175,8 +176,9 @@ class _jinja2_vars(object):
else:
raise KeyError("undefined variable: %s" % varname)
var = self.vars[varname]
# HostVars is special, return it as-is
if isinstance(var, dict) and type(var) != dict:
# HostVars is special, return it as-is, as is the special variable
# 'vars', which contains the vars structure
if isinstance(var, dict) and varname == "vars" or isinstance(var, HostVars):
return var
else:
return template(self.basedir, var, self.vars, fail_on_undefined=self.fail_on_undefined)