ping_check/ping.yml
2024-03-28 15:27:22 -04:00

31 lines
727 B
YAML

---
- name: Ping check to determine if hosts are reachable
hosts: all
become: true
gather_facts: false
tasks:
- name: Wait for connection
ansible.builtin.wait_for_connection:
timeout: 3
- name: Ping target hosts
ansible.builtin.command:
cmd: whoami
changed_when: false
register: ping_check
ignore_errors: true
# ignore_unreachable: true
failed_when: false
- name: Clear host errors
ansible.builtin.meta: clear_host_errors
- name: Display ping check results
ansible.builtin.debug:
msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}"
run_once: true # noqa: run-once[task]
delegate_to: localhost
...