From 2f05e95d8a3e54f2a9c9449867a2f9e8fb17f8c4 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 25 Oct 2012 15:13:34 +0200 Subject: [PATCH] Use lookup plugins for task include with_* --- lib/ansible/playbook/play.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 349618faa1..06a4a8ed30 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -104,10 +104,16 @@ class Play(object): if 'include' in x: task_vars = self.vars.copy() tokens = shlex.split(x['include']) - if 'with_items' in x: - items = utils.varReplaceWithItems(self.basedir, x['with_items'], task_vars) - else: - items = [''] + items = [''] + for k in x: + if not k.startswith("with_"): + continue + plugin_name = k[5:] + if plugin_name not in self.playbook.lookup_plugins_list: + raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name)) + terms = utils.varReplaceWithItems(self.basedir, x[k], task_vars) + items = self.playbook.lookup_plugins_list[plugin_name].LookupModule(None).run(terms) + for item in items: mv = task_vars.copy() mv['item'] = item