mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Use lookup plugins for task include with_*
This commit is contained in:
parent
026e251b94
commit
2f05e95d8a
1 changed files with 10 additions and 4 deletions
|
@ -104,10 +104,16 @@ class Play(object):
|
||||||
if 'include' in x:
|
if 'include' in x:
|
||||||
task_vars = self.vars.copy()
|
task_vars = self.vars.copy()
|
||||||
tokens = shlex.split(x['include'])
|
tokens = shlex.split(x['include'])
|
||||||
if 'with_items' in x:
|
items = ['']
|
||||||
items = utils.varReplaceWithItems(self.basedir, x['with_items'], task_vars)
|
for k in x:
|
||||||
else:
|
if not k.startswith("with_"):
|
||||||
items = ['']
|
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:
|
for item in items:
|
||||||
mv = task_vars.copy()
|
mv = task_vars.copy()
|
||||||
mv['item'] = item
|
mv['item'] = item
|
||||||
|
|
Loading…
Add table
Reference in a new issue