It worked. Thanks, much !! On Monday, 25 November 2019 19:23:44 UTC+5:30, Stefan Hornburg (Racke) wrote: > > On 11/25/19 2:42 PM, Pandu jh wrote: > > > > I need to reject "none" value item in ping test task. It has to take > only "non- none" values from the with_items in the > > task. > > Please help me to fix this. > > > > - set_fact: > > linux_ip: "{{ item.stdout_lines[0] }}" > > unix_ip: "{{ item.stdout_lines[1] | default('none') }}" > > loop: "{{ ip_address_api.results }}" > > > > - debug: var=unix_ip > > - debug: var=linux_ip > > > > > > - name: Ping Test > > win_shell: | > > if (Test-Connection {{ item }} -Quiet -Count 2) { > > write-host "Ping - Successful" > > } > > else { > > Write-Host "Ping - Failed" > > } > > register: ping_check > > ignore_errors: yes > > with_items: > > - "{{ unix_ip }}" > > - "{{ linux_ip }}" > > - debug: var=ping_check > > I can imagine various solutions to the problem, but > > when: "item != 'none'" > > should do the trick. > > Regards > Racke > > > > > I tired with reject filter but it did not work. > > > > - name: Ping Test > > win_shell: | > > if (Test-Connection {{ item }} -Quiet -Count 2) { > > write-host "Ping - Successful" > > } > > else { > > Write-Host "Ping - Failed" > > } > > register: ping_check > > ignore_errors: yes > > with_items: > > - "{{ unix_ip | reject('match','none) | list }}" > > - "{{ linux_ip }}" > > - debug: var=ping_check > > > > > > -- > > >
-- 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/cc51ca8e-e5bb-4ced-9504-00af2e51c3f0%40googlegroups.com.