“How should I get started with Network Automation?”
I am often asked this question by network engineers looking to develop new programming skills. If you are brand new to writing Python scripts and are looking for an easy on-ramp to the network automation superhighway, I’d suggest starting with Jinja2 – the de-facto python template engine. Template building is simply the process of creating text files by combining a reusable form (a.k.a. “template”) and the data necessary to render the result — basically a fancy “mail-merge”.
Here’s why I suggest starting with template building:
- It’s harmless – zero blast radius to the network
- Helps you – develop good programming skills
- Instant gratification – day one you will do something that will help with your job
- Multipurpose – can be used for more than just building configuration files
If you want to get started right away, I’ve posted a series of short Jinja2 tutorial videos:
- Jinja2 – 101 – Introduction to Jinja2 template building
- Jinja2 – 102 – Adding custom filters for data manipulation (super handy)
- Jinja2 – 103 – Using “include” to import data-files (like ssh-keys)
- Jinja2 – 104 – Using “if / then / else” for conditional template building
- Jinja2 – 105 – Using CSV file to create multiple host-specific configurations
The process doesn’t require any networking equipment. You don’t need to actually do anything with the result; but of course you will want to at some point.
Develop Programming Skills
Learn to think like a programmer without being a hardcore developer. There are basic programming skills such as how to organize data and create re-usable “code” (templates) that takes practice. You can start by taking your existing configuration files and transform them into reliable and reusable templates. The Jinja2 template engine is a “mini programming” language – effectively programming with guardrails. As you practice these new skills they will directly help you write more sophisticated Python programs if that’s something you want to do.
There is actually very little Python programming needed to perform basic template building. So it’s easy to get started, and you will immediate see the fruits of your efforts.
Most people think “configuration building”, but there is a lot more you can do. The data you use to create configurations can be used for other automation tasks. You could use Jinja2 to:
- create service-specific troubleshooting guides
- create simple reports
- use templates with DevOp automation tools
Getting started with Python and Jinja2 is simple, easy, and dare I say fun. I hope you find the video tutorials helpful. If you are interested in seeing additional topics added to the Jinja2 series or other Python topics in general, please send me an email or hit me up on Twitter. I am always happy to help empower our community.