mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
19703617b8
commit
128c10b311
1 changed files with 4 additions and 2 deletions
|
@ -166,6 +166,7 @@ class _jinja2_vars(object):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __getitem__(self, varname):
|
def __getitem__(self, varname):
|
||||||
|
from ansible.runner import HostVars
|
||||||
if varname not in self.vars:
|
if varname not in self.vars:
|
||||||
for i in self.extras:
|
for i in self.extras:
|
||||||
if varname in i:
|
if varname in i:
|
||||||
|
@ -175,8 +176,9 @@ class _jinja2_vars(object):
|
||||||
else:
|
else:
|
||||||
raise KeyError("undefined variable: %s" % varname)
|
raise KeyError("undefined variable: %s" % varname)
|
||||||
var = self.vars[varname]
|
var = self.vars[varname]
|
||||||
# HostVars is special, return it as-is
|
# HostVars is special, return it as-is, as is the special variable
|
||||||
if isinstance(var, dict) and type(var) != dict:
|
# 'vars', which contains the vars structure
|
||||||
|
if isinstance(var, dict) and varname == "vars" or isinstance(var, HostVars):
|
||||||
return var
|
return var
|
||||||
else:
|
else:
|
||||||
return template(self.basedir, var, self.vars, fail_on_undefined=self.fail_on_undefined)
|
return template(self.basedir, var, self.vars, fail_on_undefined=self.fail_on_undefined)
|
||||||
|
|
Loading…
Reference in a new issue