From 5f98ee878ee4fbf49a34b2d8f25d40ea01973783 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 12 Apr 2018 20:54:04 +0200 Subject: [PATCH] Give hint when lookup fails on one element list (#38406) (#38480) (cherry picked from commit 81a8c4211570fd1a5d1a2d9144db4beede2c9e1a) --- lib/ansible/executor/task_executor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index c225b2d425e..35a8766cba1 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -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