On Fri, 3 Nov 2023 08:40:19 -0700 (PDT) Dimitri Yioulos <dimitri.g.yiou...@gmail.com> wrote:
> --- PING REPORT --- > {% for pr in ping_result.results %} > {{ pr.stdout_lines | first }} > {{ pr.stdout_lines | last }} > > {% endfor %} > run_once: true > delegate_to: localhost > > That works fine. However, I want to use ansible.builtin.ping ... Ignore unreachable hosts in a block - block: - ping: register: out - set_fact: unr: "{{ out.unreachable|d(false) }}" ignore_unreachable: true and declare the dictionary h_unr: "{{ dict(ansible_play_hosts_all| zip(ansible_play_hosts_all| map('extract', hostvars, 'unr'))) }}" For example, the below play - hosts: test_01,test_05,test_06,test_07 gather_facts: false vars: h_unr: "{{ dict(ansible_play_hosts_all| zip(ansible_play_hosts_all| map('extract', hostvars, 'unr'))) }}" tasks: - block: - ping: register: out - set_fact: unr: "{{ out.unreachable|d(false) }}" ignore_unreachable: true - debug: var: h_unr run_once: true delegate_to: localhost gives (abridged) ok: [test_01 -> localhost] => h_unr: test_01: false test_05: true test_06: true test_07: true -- Vladimir Botka -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20231106205809.164c42fb%40gmail.com.
pgpEoJmLL1d_d.pgp
Description: OpenPGP digital signature