From c200c26cedcd4c4cfaefbf8f2f1814812e427009 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 13 Nov 2012 11:34:34 +0100 Subject: [PATCH] Keep hostvars from being templated --- lib/ansible/utils/template.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index db6e7fa754..7e7b984fe4 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -248,7 +248,12 @@ class _jinja2_vars(object): def __getitem__(self, varname): if varname not in self.vars: raise KeyError("undefined variable: %s" % varname) - return template_ds(self.basedir, self.vars[varname], self.vars) + var = self.vars[varname] + # HostVars is special, return it as-is + if isinstance(var, dict) and type(var) != dict: + return var + else: + return template_ds(self.basedir, var, self.vars) def template_from_file(basedir, path, vars): ''' run a file through the templating engine '''