30 lines
698 B
YAML
30 lines
698 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: Test target host connectivity
|
|
ansible.builtin.command:
|
|
cmd: whoami
|
|
changed_when: false
|
|
register: ping_check
|
|
ignore_errors: true
|
|
failed_when: false
|
|
|
|
- name: Clear host errors
|
|
ansible.builtin.meta: clear_host_errors
|
|
|
|
- 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
|
|
|
|
...
|