How it works...

We use the junos_ping module in order to ping from all the nodes in our network inventory to all the loopback interfaces defined in the lo_ip data structure, which is defined in the group_vars/all.yml file. This module connects to each device and executes ping to all the destinations, and validates that ping packets are reaching their intended destination. This module requires the use of the network_cli connection plugin, therefore we supply this parameter as a task variable in order to override the group-level NETCONF connection plugin defined at the group level.

We register the output of the module in order to use this data to generate the ping report. Finally, we set ignore_errors to yes in order to ignore any failed ping task that we might encounter, and ensure that we will run the subsequent tasks to create the report.

We use the blockinfile module in order to create a custom report in Markdown. We use a table layout in order to capture the ping results and display a table that captures these ping results. The following snippet captures the table generated for the mxpe01 ping test report:

$ cat ping_report.md

# BEGIN ANSIBLE MANAGED BLOCK
Node | Destination | Packet Loss | Delay |
-----| ------------| ------------| ------|
mxpe01 | 10.100.1.254/32 | 0% | 3.75
mxpe01 | 10.100.1.253/32 | 0% | 2.09
mxpe01 | 10.100.1.1/32 | 0% | 0.27
mxpe01 | 10.100.1.2/32 | 0% | 4.72
mxpe01 | 10.100.1.3/32 | 100% | 'N/A'
# END ANSIBLE MANAGED BLOCK

Here is the rendered Markdown table for the ping result: