Looking for a Tool to Create Device Configurations from Templates
One of my readers sent me this question:
Other than using Excel (and of course an automation tool) any suggestions for a tool to create device config for some 200 customer VRFs from a standard template?
You need three things to get the job done:
- Data (what values you want to have in each configuration)
- Templating tool and configuration templates
- Some glue that connects the two and generates the configurations.
You can store data in text files (CSV or YAML), Excel spreadsheets, or a database (any database would do, but object-oriented databases might be a better fit than relational ones).
However, when selecting a potential data store, keep in mind that (as I explained in the Data Stores part of the Data Model section in my Building Network Automation Solutions course) you have to:
- Have a tool to update the data, and while databases have numerous interesting properties, its way easier to use Notepad, Sublime Text or Excel to update the data;
- Have a mechanism to track changes to the data, and a Git repository is way simpler to implement than any alternative.
Next you need a templating tool. Every programming language has one, and as Python is the new black, you might want to go with Jinja2.
Finally, you need some glue that will take device-specific data, push it through a template, and save the results in a file. Writing a Python script to do that is really easy (unless it’s your first script).
However, the moment you have a tool, you want a more powerful tool. For example, you might want to have global parameters, or groups of devices, or push configurations to the devices, or… and this is where Ansible starts making perfect sense for a minimum investment in tools and programming.
There are people who prefer to do the undifferentiated heavy lifting, and then there are the lazy people (like myself) who like to use the tools that are out there, and once I got familiar with YAML/Jinja2/Ansible combo I wouldn't even think about writing my own Python script to get the job done, but that's just me.
Sounds interesting? Why don’t you explore the Ansible for Networking Engineers webinar, and once you get interested in writing real-life solutions join the Building Network Automation Solutions course?
Enter Ansible and the "xls_to_facts" module I found. Since spreadsheets were already a familiar data store, I stuck with that. I created tabs for various features (global config items, AAA, users, VLANs, VRFs, etc.) then wrote the Jinja to insert the data if it was defined in the spreadsheet, otherwise skip that section of the script. You could keep it as simple as needed or define a lot of stuff.
Customer express what he/she wants to change in the system (add new system components - not router or switch!) and this request through the GUI sparks actions. As a consequence many networking devices are configured using templates to fullfil the system change required by the Customer.
It's another use of automation implemented many years ago.
Side note: automation has been always used in big vendors testing labs - I spent more than 12 years in such environments where hundreds of devices are configured at once.
https://github.com/verbosemode/confplate