using facts instead of template lookup
This commit is contained in:
parent
fe61a6d9ce
commit
247d4899db
23
ping.yml
23
ping.yml
@ -7,7 +7,7 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: Wait for connection
|
- name: Wait for connection
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: 3
|
timeout: 5
|
||||||
|
|
||||||
- name: Test target host connectivity
|
- name: Test target host connectivity
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
@ -20,9 +20,26 @@
|
|||||||
- name: Clear host errors
|
- name: Clear host errors
|
||||||
ansible.builtin.meta: clear_host_errors
|
ansible.builtin.meta: clear_host_errors
|
||||||
|
|
||||||
- name: Ping check results
|
# - 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
|
||||||
|
|
||||||
|
- name: Set facts
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
successful_hosts: "{{ successful_hosts | default([]) + ansible_play_batch }}"
|
||||||
|
failed_hosts: "{{ failed_hosts | default([]) + ansible_play_hosts_all | difference(ansible_play_batch) }}"
|
||||||
|
|
||||||
|
- name: Successful Hosts
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ lookup('template', 'ping_results.j2') | from_yaml }}"
|
msg: "{{ successful_hosts }}"
|
||||||
|
run_once: true # noqa: run-once[task]
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Failed Hosts
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ failed_hosts }}"
|
||||||
run_once: true # noqa: run-once[task]
|
run_once: true # noqa: run-once[task]
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user