Skip to content

Commit

Permalink
Don't template 'vars' dictionary during templating
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Sep 25, 2014
1 parent 1970361 commit 128c10b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ansible/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def __contains__(self, k):
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:
Expand All @@ -175,8 +176,9 @@ def __getitem__(self, varname):
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)
Expand Down

0 comments on commit 128c10b

Please sign in to comment.