move to template for ping results

This commit is contained in:
Chris Hammer 2024-03-28 10:25:47 -04:00
parent 7cd7a8f386
commit 5e84ca0745
2 changed files with 11 additions and 8 deletions

View File

@ -11,15 +11,9 @@
ignore_errors: true
failed_when: false
- name: "Ping Check: Successful Hosts"
- name: Display ping check results
ansible.builtin.debug:
msg: "{{ ansible_play_batch }}"
run_once: true # noqa: run-once[task]
delegate_to: localhost
- name: "Ping Check: Failed Hosts"
ansible.builtin.debug:
msg: "{{ ansible_play_hosts_all | difference(ansible_play_batch) }}"
msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}"
run_once: true # noqa: run-once[task]
delegate_to: localhost

View File

@ -0,0 +1,9 @@
success_hosts:
{% for shost in ansible_play_batch %}
- "{{ shost }}"
{% endfor %}
failed_hosts:
{% for fhost in ansible_play_hosts_all | difference(ansible_play_batch) %}
- "{{ fhost }}"
{% endfor %}