From 233a36b9e8e762a8f2b654ee7c24e8f544489bc9 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 12 Nov 2012 16:52:50 +0100 Subject: [PATCH] Template using module_vars early Since no basedir is available at that time, avoid invoking lookup plugins since they assume it is present. --- lib/ansible/playbook/task.py | 3 +++ lib/ansible/utils/template.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 4e973710472..0ccc4c57df6 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -149,6 +149,9 @@ class Task(object): # allow the user to list comma delimited tags import_tags = import_tags.split(",") + self.name = utils.template(None, self.name, self.module_vars) + self.action = utils.template(None, self.action, self.module_vars) + # handle mutually incompatible options incompatibles = [ x for x in [ self.first_available_file, self.items_lookup_plugin ] if x is not None ] if len(incompatibles) > 1: diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index 256398dd075..b01010622fa 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -215,7 +215,8 @@ def template(basedir, text, vars, expand_lists=False): except UnicodeEncodeError: pass # already unicode text = varReplace(unicode(text), vars, expand_lists=expand_lists) - text = _varReplaceLookups(basedir, text, vars) + if basedir is not None: + text = _varReplaceLookups(basedir, text, vars) return text def template_from_file(basedir, path, vars):