Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup plugin arguments need to be templated #1621

Merged
merged 1 commit into from
Nov 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ansible/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/TestUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ def test_template_varReplace_iterated(self):
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'

Expand Down