Earlier this year I blogged about Using APIC-EM as the single source of truth. Since then, APIC-EM as become GA and I've updated my Ansible module shown in that post to use the GA release.
A WWT customer recently requested the capability to automate the collection of output from a series of 'show' commands from routers and switches. An example of the Ansible playbook to accomplish that task is available on GitHub.
We can leverage that development effort into a demonstration of using APIC-EM and Ansible to provide an Asset and Lifecycle management tool.
For this use case, we will use the APIC-EM database of discovered devices to provide an inventory of routers to the Ansible playbook, and specify the commands to be issued on the router. For example:
However, rather than issue the commands on all the devices in the inventory, we will use the facts provided by APIC-EM to filter on only selected devices in the inventory. This playbook will only issue the commands for Cisco 2911 routers running IOS version 15.3(3)M5.
The output of the show commands are stored in files specific to each device in inventory, and following the execution of the playbook, we can glean additional information from the collected data. As an example, we can grep the files to determine which devices have 4 Port GE Non-POE EHWICs based on the captured output.
By combining APIC-EM, Ansible and the WWT developed modules, we can easily identify network devices which meet our selection criteria by using APIC-EM for an inventory and by modifying a simple Ansible playbook and issuing basic Linux commands.