move to template for ping results
This commit is contained in:
parent
7cd7a8f386
commit
5e84ca0745
10
ping.yml
10
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
|
||||
|
||||
|
9
templates/ping_results.j2
Normal file
9
templates/ping_results.j2
Normal 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 %}
|
Loading…
x
Reference in New Issue
Block a user