

4 #doesn't exist to do the example more interesting So, here we have two loops: - name: Get home files with names from 1 to 4 Running the playbook is as easy as running any other Ansible Playbook – ansible-playbook scenario is that we have two different loops, and we want to operate their result together with a with_nested. You can also see the output is stored in a folder called show-output and the file name is the hostname of the device as it appears in the inventory file. Without this fix the output was just one big blog of text that wasn’t very human readable.

” rather than “\n” A co-worker of mine came to me with this issue and we tried to solve it together, he found the fix before I did. Ansible was catching the raw output the router was sending over the wire to the terminal emulator software, and for some reason it was getting “ ’, ‘\n'” \n is the ASCII symbol for new line. Notice in the beginning of the second play – “replace ‘ The first play will run the show commands we want the output for, the second play pipes the output to texts files saved on the Ansible server. The Ansible Playbook for this one is going to be pretty simple, only 2 plays. So, what show commands do we need now? Let’s do a full show run to verify all the new configuration took, a show ip route to ensure that we’ve learned all the new routes we’d expect to, a show ip eigrp neighbors to ensure our adjacencies have formed, and lastly let’s do a show version so we can prepare for an upcoming IOS upgrade. Let’s run a playbook to capture the output of some show commands that will verify our previous playbooks deployed successfully. In my previous lab articles we did some baseline config and then configured some interfaces for simulated WAN and LAN connections, and we configured EIGRP on the WAN interfaces. Ansible is really great at automation and this includes capturing show output. Even though there’s only four of them it’ll still take me so time to connect to each, run the show commands, capture the output, and so forth. I have four routers in my lab and let’s say I want to capture show output from each. Let’s do this!īut first, if you’re not yet familiar with Ansible I’d like to direct you to my “ Starting your Automation Journey with Ansible” mini series. In this article I’ll show you an Ansible Playbook that captures show output from multiple show commands on a Cisco router, and then stores the output in a text file that is the hostname of the device.
