I am trying to solve a network automation issue. The issue is we have a strange behaviour of network devices (SNOM Phones) connected in a chain to the certain Cisco switch port. The thing is the one of such phones (every time the different one) is disappearing randomly, and after that such device can't get a IP address via DHCP. We still did not found the way to reproduce the issue, so I've enabled debug logs at the DHCP server and now awaiting then one of mac addresses will disappear from the switch interface mac address table.
And as cisco do not support linux 'watch' command, I've wrote a simple ansible playbook for such purpose:
---
- name: show mac address-table
hosts: ios
gather_facts: no
tasks:
- name: show mac address-table interface Fa0/31
ios_command:
commands: show mac address-table interface Fa0/31
wait_for:
- result[0] contains 0004.1341.799e
- result[0] contains 0004.134a.f67d
- result[0] contains 0004.138e.1a53
register: result
until: result is failed
retries: 1000
- debug: var=result
But in that configuration i see the only
FAILED - RETRYING: show mac address-table interface Fa0/31 (660 retries left).
FAILED - RETRYING: show mac address-table interface Fa0/31 (659 retries left).
FAILED - RETRYING: show mac address-table interface Fa0/31 (658 retries left).
FAILED - RETRYING: show mac address-table interface Fa0/31 (657 retries left).
at the output. I've tried to use anstomlog callback plugin, but it show the timestamps only for the succeded conditions (i.e. in my case - then result is failed)
So, I am looking for an advice, how to achieve both goals:
- run task forever until status get failed
- write timestams of every single retry
Thanks in advance!