From e74ffd6764271be48fb3af3e4407d6a1572a0294 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Wed, 14 Nov 2012 11:16:53 +0100 Subject: [PATCH] Lookup plugin arguments need to be templated --- lib/ansible/utils/template.py | 2 ++ test/TestUtils.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index 7e7b984fe4..6e8893e2c8 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -157,6 +157,8 @@ def _varFind(basedir, text, vars, depth=0): if lookup_plugin_name == 'LOOKUP': lookup_plugin_name, args = args.split(",", 1) args = args.strip() + # args have to be templated + args = varReplace(basedir, args, vars, depth=depth+1, expand_lists=True) instance = utils.plugins.lookup_loader.get(lookup_plugin_name.lower(), basedir=basedir) if instance is not None: replacement = instance.run(args, inject=vars) diff --git a/test/TestUtils.py b/test/TestUtils.py index 1cf6e61bf2..7b748919ed 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -272,9 +272,9 @@ class TestUtils(unittest.TestCase): assert res == u'hello oh great one' def test_varReplace_include(self): - template = 'hello $FILE(world) $LOOKUP(file, world)' + template = 'hello $FILE(world) $LOOKUP(file, $filename)' - res = ansible.utils.template("test", template, {}, expand_lists=True) + res = ansible.utils.template("test", template, {'filename': 'world'}, expand_lists=True) assert res == u'hello world world'