diff --git a/ping.yml b/ping.yml index bcb7800..12e8629 100644 --- a/ping.yml +++ b/ping.yml @@ -1,25 +1,29 @@ --- - name: Ping check to determine if hosts are reachable hosts: all - become: false + become: true gather_facts: false tasks: + - name: Wait for connection + ansible.builtin.wait_for_connection: + timeout: 3 + - name: Ping target hosts - ansible.builtin.ping: + ansible.builtin.command: + cmd: whoami + changed_when: false register: ping_check ignore_errors: true + # ignore_unreachable: true failed_when: false - - name: Set ping check results - ansible.builtin.set_fact: - ping_results: "{{ lookup('template', 'ping_results.j2') | from_yaml }}" - run_once: true # noqa: run-once[task] - delegate_to: localhost + - name: Clear host errors + ansible.builtin.meta: clear_host_errors - name: Display ping check results ansible.builtin.debug: - var: ping_results + msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}" run_once: true # noqa: run-once[task] delegate_to: localhost