diff --git a/ping.yml b/ping.yml index d236069..a101821 100644 --- a/ping.yml +++ b/ping.yml @@ -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 diff --git a/templates/ping_results.j2 b/templates/ping_results.j2 new file mode 100644 index 0000000..5c6e422 --- /dev/null +++ b/templates/ping_results.j2 @@ -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 %}