I've been trying to use Ansible to print the CRC count using the ip -s -s link show
command in a Red Hat machine. My stdout_lines
is a list with below output:
"stdout_lines": [
"1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000",
" link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00",
" RX: bytes packets errors dropped overrun mcast ",
" 0 0 0 0 0 0 ",
" RX errors: length crc frame fifo missed",
" 0 0 0 0 0 ",
" TX: bytes packets errors dropped carrier collsns ",
" 0 0 0 0 0 0 ",
" TX errors: aborted fifo window heartbeat transns",
" 0 0 0 0 0 ",
"2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000",
" link/ether 00:15:5d:e3:bb:dd brd ff:ff:ff:ff:ff:ff",
" RX: bytes packets errors dropped overrun mcast ",
" 102522514 69859 0 0 0 1205 ",
" RX errors: length crc frame fifo missed",
" 0 0 0 0 0 ",
" TX: bytes packets errors dropped carrier collsns ",
" 1179376 15194 0 0 0 0 ",
" TX errors: aborted fifo window heartbeat transns",
" 0 0 0 0 5 "
]
So far I have tried these steps to create an Ansible playbook
- Read the line numbered
1:
,2:
and map the interfaceslo
,eth0
- Now read the lines and search the line with "
RX errors: crc
" for each interface (lo
,eth0
) - Also read the lines below "
RX errors: crc
" line and print the value for CRC column
But I did not succeed. Any suggestion is welcome.