From 128c10b3111b3bb6f0fac8bbbeddc8b2766ecbf7 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 25 Sep 2014 14:46:16 -0500 Subject: [PATCH] Don't template 'vars' dictionary during templating Fixes #9132 --- lib/ansible/utils/template.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index d1026590033..9521f2f2ece 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -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)