Make template_ds the only templater

Instead of having to remember when to use which one, rename template_ds
to template and move the last bit of code from template to varReplace
(which gets used for all string replacements, in the end).

This means that you can template any data type without worrying about
whether it's a string or not, and the right thing will happen.
This commit is contained in:
Daniel Hokka Zakrisson 2013-02-02 12:29:28 +01:00
parent 42daffdb38
commit a79373f6b2
5 changed files with 21 additions and 30 deletions

View file

@ -75,10 +75,8 @@ class Play(object):
self.transport = ds.get('connection', self.playbook.transport)
self.tags = ds.get('tags', None)
self.gather_facts = ds.get('gather_facts', None)
self.serial = int(utils.template_ds(basedir, ds.get('serial', 0), self.vars))
if isinstance(self.remote_port, basestring):
self.remote_port = utils.template(basedir, self.remote_port, self.vars)
self.serial = int(utils.template(basedir, ds.get('serial', 0), self.vars))
self.remote_port = utils.template(basedir, self.remote_port, self.vars)
self._update_vars_files_for_host(None)
@ -117,7 +115,7 @@ class Play(object):
plugin_name = k[5:]
if plugin_name not in utils.plugins.lookup_loader:
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
terms = utils.template_ds(self.basedir, x[k], task_vars)
terms = utils.template(self.basedir, x[k], task_vars)
items = utils.plugins.lookup_loader.get(plugin_name, basedir=self.basedir, runner=None).run(terms, inject=task_vars)
elif k.startswith("when_"):
included_additional_conditions.append(utils.compile_when_to_only_if("%s %s" % (k[5:], x[k])))
@ -136,7 +134,7 @@ class Play(object):
mv['item'] = item
for t in tokens[1:]:
(k,v) = t.split("=", 1)
mv[k] = utils.template_ds(self.basedir, v, mv)
mv[k] = utils.template(self.basedir, v, mv)
include_file = utils.template(self.basedir, tokens[0], mv)
data = utils.parse_yaml_from_file(utils.path_dwim(self.basedir, include_file))
results += self._load_tasks(data, mv, included_additional_conditions)