From 4a93c247bd156699004a8e857fa6a9012635bee5 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 1 Jun 2013 18:22:56 -0400 Subject: [PATCH] Another lookup plugin relative path tweak. --- lib/ansible/runner/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 8bf8d6f7c11..a0d7688e1f8 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -392,9 +392,16 @@ class Runner(object): if items_plugin is not None and items_plugin in utils.plugins.lookup_loader: + basedir = self.basedir + if '_original_file' in inject: + basedir = os.path.dirname(inject['_original_file']) + filesdir = os.path.join(basedir, '..', 'files') + if os.path.exists(filesdir): + basedir = filesdir + items_terms = self.module_vars.get('items_lookup_terms', '') - items_terms = template.template(self.basedir, items_terms, inject) - items = utils.plugins.lookup_loader.get(items_plugin, runner=self, basedir=self.basedir).run(items_terms, inject=inject) + items_terms = template.template(basedir, items_terms, inject) + items = utils.plugins.lookup_loader.get(items_plugin, runner=self, basedir=basedir).run(items_terms, inject=inject) if type(items) != list: raise errors.AnsibleError("lookup plugins have to return a list: %r" % items)