mirror of https://github.com/ansible/ansible.git
Fix returning unreachable for looped tasks (#84049)
* Fix returning unreachable for looped tasks Add tests for ignore_unreachable and looppull/84210/head
parent
a3b58fb67c
commit
03acb22f99
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- Fix returning 'unreachable' for the overall task result. This prevents false positives when a looped task has unignored unreachable items (https://github.com/ansible/ansible/issues/84019).
|
||||
@ -0,0 +1,41 @@
|
||||
- hosts: localhost,nonexistent
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Test ignore_unreachable for all items (pass)
|
||||
ping:
|
||||
ignore_unreachable: "{{ item.ignore_unreachable }}"
|
||||
loop:
|
||||
- ignore_unreachable: true
|
||||
- ignore_unreachable: true
|
||||
register: unreachable_ignored
|
||||
|
||||
- name: Test ignore_unreachable for second item (fail)
|
||||
ping:
|
||||
ignore_unreachable: "{{ item.ignore_unreachable }}"
|
||||
loop:
|
||||
- ignore_unreachable: false
|
||||
- ignore_unreachable: true
|
||||
register: unreachable_first
|
||||
|
||||
- meta: clear_host_errors
|
||||
|
||||
- name: Test ignore_unreachable for first item (fail)
|
||||
ping:
|
||||
ignore_unreachable: "{{ item.ignore_unreachable }}"
|
||||
loop:
|
||||
- ignore_unreachable: true
|
||||
- ignore_unreachable: false
|
||||
register: unreachable_last
|
||||
|
||||
- meta: clear_host_errors
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- unreachable_ignored is not unreachable
|
||||
- unreachable_first["results"][0] is unreachable
|
||||
- unreachable_first["results"][-1] is not unreachable
|
||||
- unreachable_first is unreachable
|
||||
- unreachable_last["results"][-1] is unreachable
|
||||
- unreachable_last["results"][0] is not unreachable
|
||||
- unreachable_last is unreachable
|
||||
when: inventory_hostname == 'nonexistent'
|
||||
Loading…
Reference in New Issue