diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index d6b8eff17d..297d8b2526 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -153,7 +153,8 @@ class TaskExecutor: items = None if self._task.loop: if self._task.loop in self._shared_loader_obj.lookup_loader: - items = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar).run(terms=self._task.loop_args, variables=vars_copy) + loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=True) + items = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar).run(terms=loop_terms, variables=vars_copy) else: raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % self._task.loop)