- hosts: test-vms
tasks:
- name: Ping vms in test-vms
ansible.builtin.ping:
register: ping_pong
ignore_errors: True
- hosts: localhost
gather_facts: no
tasks:
- name: Copy the output result to /tmp/file.txt
ansible.builtin.template:
src: ping.j2
dest: /tmp/file.txt
ping.j2:
{% for host in groups['test-vms'] %}
{{ host }}: {{ hostvars[host]['ping_pong'] }}
{% endfor %}
--
----------
Brian Coca
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CACVha7e2iowLyrwg6kHJShF2KcTygu5guXQKEL0ki8SA_-_bLg%40mail.gmail.com.