This commit is contained in:
Chris Hammer 2024-03-28 15:27:22 -04:00
parent 6a567185b3
commit 888b6f3362

View File

@ -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