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 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1f050f15-5ff1-456e-8726-16a316578dd4%40googlegroups.com.