Sure, here is the gist
https://gist.github.com/vbotka/10c57962976dd1e2dd3e9411d3745c75

(Is it possible to reasonably format a code in Google Groups?)
On Tuesday, November 7, 2023 at 6:55:50 PM UTC+1 dbs34 wrote:

> would you mind sharing the whole, newly updated playbook?  thank you!
>
> On Monday, November 6, 2023 at 2:58:31 PM UTC-5 Vladimir Botka wrote:
>
>> On Fri, 3 Nov 2023 08:40:19 -0700 (PDT) 
>> Dimitri Yioulos <dimitri....@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/af3ef710-2205-48b8-9004-84da0cf9f27an%40googlegroups.com.

Reply via email to