Not long ago I did a short demo at the sixth iNOG meeting, which saw around one hundred netengs get together at Facebook's Dublin HQ for an amazing evening. The point of the demo was to show people to how easy it is to write a bit of code to quickly generate device configuration from a template.

The readme

I had no slides, only a short text document with a few links and this article serves that purpose (if you're coming over from

The script

Config generation is basic stuff and many have done it already in various forms in the past (likely with Excel), but it also is a piece of automation that has immediate and tangible impact.

I had people come to me afterwards saying that they liked seeing an example of how it can be done with Python and asking how much effort it would take to write something like that from scratch. The answer, of course, depends on one's prior knowledge of coding: as long as basic data structures and algorithms are understood, it shouldn't take more than an hour or two to get something working, using Python docs and Google/StackOverflow.

After that initial prototype, more effort should go into making it user friendly, adding some sanity checking and comments in the code. Oh and don't forget to remove all the hard-coded values, they're ugly - Python has a very nice module called argparse that makes adding command line parameters to your script a breeze.

I've made the script available on GitHub together with an example Jinja2 template, a csv file and a short tutorial.

My demo was recorded and you can watch it on YouTube, together with all the other talks from iNOG::6.

The bottom line is automation doesn't have to be complicated or applied on a scale so grand it's hard to even know where to start. Find a realistic goal (a small problem you can solve), build a prototype to prove it can be done and then iterate on it, making it better and better at what it does.

The next step

Generating config is nice and all, but someone has to apply it to a blank router afterwards. There's no easy or standard way of doing it (unless you call copy-paste in a console terminal standard) but I've been given some nice ideas about how to do it on Cisco IOS and that's what my next demo might be about.

If you'd like to talk about this, post a comment below or find me on the iNOG Slack.

And, as always, thanks for reading.

comments powered by Disqus