mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Ensure that an empty literal list with loop skips the task (#47129)
This commit is contained in:
parent
4fc6ab55aa
commit
02f4d0a57f
3 changed files with 9 additions and 1 deletions
2
changelogs/fragments/loop-empty-literal-list.yaml
Normal file
2
changelogs/fragments/loop-empty-literal-list.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- loop - Do not evaluate a empty literal list ``[]`` as falsy, it should instead cause the task to skip ()
|
|
@ -236,7 +236,7 @@ class TaskExecutor:
|
||||||
else:
|
else:
|
||||||
raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % self._task.loop_with)
|
raise AnsibleError("Unexpected failure in finding the lookup named '%s' in the available lookup plugins" % self._task.loop_with)
|
||||||
|
|
||||||
elif self._task.loop:
|
elif self._task.loop is not None:
|
||||||
items = templar.template(self._task.loop)
|
items = templar.template(self._task.loop)
|
||||||
if not isinstance(items, list):
|
if not isinstance(items, list):
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
|
|
|
@ -252,3 +252,9 @@
|
||||||
loop: "{{ fake_var }}"
|
loop: "{{ fake_var }}"
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is not skipped
|
failed_when: result is not skipped
|
||||||
|
|
||||||
|
- name: Loop on literal empty list
|
||||||
|
debug:
|
||||||
|
loop: []
|
||||||
|
register: literal_empty_list
|
||||||
|
failed_when: literal_empty_list is not skipped
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue