Final playbook

We are now ready to incorporate this new parser script back into our playbook. We can now add the additional task of rendering the output with graph generation in cisco_discover_lldp.yml:

 - name: Execute Python script to render output   
command: ./cisco_graph_lldp.py

The playbook can now be scheduled to run regularly via cron or other means. It will automatically query the devices for LLDP neighbors and construct the graph, and the graph will represent the current topology as known by the routers.

We can test this by shutting down the Gi0/1 and Go0/2 interfaces on r6-edge when the LLDP neighbor passes the hold time and disappears from the LLDP table:

r6-edge#sh lldp neighbors
...
Device ID Local Intf Hold-time Capability Port ID
r2.virl.info Gi0/0 120 R Gi0/0
r3.virl.info Gi0/3 120 R Gi0/2
r3.virl.info Gi0/0 120 R Gi0/0
r5-tor.virl.info Gi0/0 120 R Gi0/0
r1.virl.info Gi0/0 120 R Gi0/0

Total entries displayed: 5

The graph will automatically show that r6-edge only connects to r3:

This is a relatively long example. We used the tools we have learned so far in the book--Ansible and Python--to modularize and break tasks into reusable pieces. We then used the new tool, namely Graphviz, to help monitor the network for non-time-series data, such as network topology relationships.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.237.194