diff --git a/ping.yml b/ping.yml index 74f161d..eb2b9c1 100644 --- a/ping.yml +++ b/ping.yml @@ -7,7 +7,7 @@ tasks: - name: Wait for connection ansible.builtin.wait_for_connection: - timeout: 3 + timeout: 5 - name: Test target host connectivity ansible.builtin.command: @@ -20,9 +20,26 @@ - name: Clear host errors ansible.builtin.meta: clear_host_errors - - name: Ping check results + # - name: Ping check results + # ansible.builtin.debug: + # msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}" + # run_once: true # noqa: run-once[task] + # delegate_to: localhost + + - name: Set facts + ansible.builtin.set_fact: + successful_hosts: "{{ successful_hosts | default([]) + ansible_play_batch }}" + failed_hosts: "{{ failed_hosts | default([]) + ansible_play_hosts_all | difference(ansible_play_batch) }}" + + - name: Successful Hosts ansible.builtin.debug: - msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}" + msg: "{{ successful_hosts }}" + run_once: true # noqa: run-once[task] + delegate_to: localhost + + - name: Failed Hosts + ansible.builtin.debug: + msg: "{{ failed_hosts }}" run_once: true # noqa: run-once[task] delegate_to: localhost