As previously answered, you need to limit the amount of packets, you can try these 2 tasks:
- name: Execute ping
shell: "ping -c 4 {{ my_ip }}"
register: result
- name: Show result
debug:
msg: "{{ result['stdout_lines'] }}"
Keep in mind the "my_ip" variable was taken from a different file.
After these tasks finished, I got the following output:
"msg": [
"PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.",
"64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=3.86 ms",
"64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=3.35 ms",
"64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=3.22 ms",
"64 bytes from 8.8.8.8: icmp_seq=4 ttl=54 time=3.54 ms",
"",
"--- 8.8.8.8 ping statistics ---",
"4 packets transmitted, 4 received, 0% packet loss, time 3005ms",
"rtt min/avg/max/mdev = 3.224/3.494/3.860/0.246 ms"
]
Hope it helps!