I got this tweet after publishing the “use Ansible to execute a single command on all routers” blog post (and a few similar comments on the blog post itself)
Or use Python, Netmiko and a simple For loop
Of course you can solve the “execute one command on a few boxes” problem with Python and Netmiko (assuming you’re willing to invest your time in learning Python or wasting it with google-and-throw spaghetti wall approach).
You can also improve your script and switch into enable mode (or use authorize and auth_pass parameters in ios_command Ansible module).
You can add support for configuration commands, or you could use ios_config Ansible module or NAPALM library.
You can invest time in building a multi-threaded solution once you figure out that write memory (or show running) command executed on 100 high-end PE-routers takes too much time.
You can also figure out all the challenges of multi-threaded programming once you start stomping on your threads’ toes.
Or you could find the right tool for the job and focus on getting the job done instead of reinventing the tool… and the more tools you’re familiar with, the more likely you’ll choose the right tool for the job.
Do I have to mention that it’s easiest to get familiar with the tools if you use them in a low-risk environment like a lab?
You can also solve the next problem with another for loop (or deploy OSPF NSSA areas).
Some of you might know that I wrote quite a few “yeah, it’s just a for loop” scripts in my life, and saw them blossom into a spaghetti mess. I’ve also seen what happens when such a script grows organically to cover more platforms. Everything I wrote above is unfortunately based on my personal experience (and learning from my own mistakes). Try not to repeat them.