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:
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue