mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Provide warning about "with_items: '{{ loop }}'" being redundant only when {{ starts the expression value. Fixes #4582.
This commit is contained in:
parent
2bd8cb5790
commit
60944b81f0
1 changed files with 2 additions and 2 deletions
|
@ -82,7 +82,7 @@ class Task(object):
|
|||
# code to allow "with_glob" and to reference a lookup plugin named glob
|
||||
elif x.startswith("with_"):
|
||||
|
||||
if isinstance(ds[x], basestring) and '{{' in ds[x]:
|
||||
if isinstance(ds[x], basestring) and ds[x].lstrip().startswith("{{"):
|
||||
utils.warning("It is unneccessary to use '{{' in loops, leave variables in loop expressions bare.")
|
||||
|
||||
plugin_name = x.replace("with_","")
|
||||
|
@ -94,7 +94,7 @@ class Task(object):
|
|||
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
|
||||
|
||||
elif x in [ 'changed_when', 'failed_when', 'when']:
|
||||
if isinstance(ds[x], basestring) and '{{' in ds[x]:
|
||||
if isinstance(ds[x], basestring) and ds[x].lstrip().startswith("{{"):
|
||||
utils.warning("It is unneccessary to use '{{' in conditionals, leave variables in loop expressions bare.")
|
||||
ds[x] = "jinja2_compare %s" % (ds[x])
|
||||
elif x.startswith("when_"):
|
||||
|
|
Loading…
Reference in a new issue