mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
Raise an error when multiple when_* statements are provided
Fixes #1994.
This commit is contained in:
parent
b0932e1638
commit
98f0a9210e
1 changed files with 2 additions and 0 deletions
|
@ -63,6 +63,8 @@ class Task(object):
|
||||||
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
|
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
|
||||||
|
|
||||||
elif x.startswith("when_"):
|
elif x.startswith("when_"):
|
||||||
|
if 'when' in ds:
|
||||||
|
raise errors.AnsibleError("multiple when_* statements specified in task %s" % (ds.get('name', ds['action'])))
|
||||||
when_name = x.replace("when_","")
|
when_name = x.replace("when_","")
|
||||||
ds['when'] = "%s %s" % (when_name, ds[x])
|
ds['when'] = "%s %s" % (when_name, ds[x])
|
||||||
ds.pop(x)
|
ds.pop(x)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue