1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Give hint when lookup fails on one element list (#38406)

* Give hint when lookup fails on one element list

* Mention wantlist first

* Fix pep8...
This commit is contained in:
Martin Krizek 2018-04-09 11:08:04 +02:00 committed by GitHub
parent 99497ce54c
commit 81a8c42115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,7 +233,11 @@ class TaskExecutor:
elif self._task.loop:
items = templar.template(self._task.loop)
if not isinstance(items, list):
raise AnsibleError("Invalid data passed to 'loop' it requires a list, got this instead: %s" % items)
raise AnsibleError(
"Invalid data passed to 'loop', it requires a list, got this instead: %s."
" Hint: If you passed a list/dict of just one element,"
" try adding wantlist=True to your lookup invocation or use q/query instead of lookup." % items
)
# now we restore any old job variables that may have been modified,
# and delete them if they were in the play context vars but not in