- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 05:57 PM
I would like to create a Python job using Jinja2 templates to create golden configs. This is easy enough, but my question is should I use one large template for the entirety of the config or split it into multiple templates (base, snmp, ntp, aaa, etc). I ask for a few reasons...
- I would like a single job for multiple switch types with require different interface syntax.
- If I wanted to do something like add a new SNMP account, having the config ready in a snippet just for SNMP would save time without having to generate a complete config.
- I would eventually like to migrate to Ansible and I feel like having the sections already split would help that transition.
Any other Python method I should consider here? Thanks.
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 11:48 PM
This was always my preferred way. We use to split the j2 files into areas such as security (ACL for example) BGP to providers, BGP to peerings etc, we had a bare base config too such as mgmt ip and usernames. You are right imo, managing one large j2 file and having this as your source of truth with what would be many changes per day and lets face it some of our running-configs get huge, smaller changes work much better.
Hope this helps.
Connect with me https://bigevilbeard.github.io

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 11:48 PM
This was always my preferred way. We use to split the j2 files into areas such as security (ACL for example) BGP to providers, BGP to peerings etc, we had a bare base config too such as mgmt ip and usernames. You are right imo, managing one large j2 file and having this as your source of truth with what would be many changes per day and lets face it some of our running-configs get huge, smaller changes work much better.
Hope this helps.
Connect with me https://bigevilbeard.github.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2023 06:13 AM
It does, thanks. So each config section is its own j2 template, then the python takes the variable input and combines all the j2 templates into one large template to be put on a switch?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2023 07:04 AM
Yes sir, this is the way. I think i had an example with Napalm here back in the day as a jinja helper https://github.com/CiscoDevNet/learning_lab_napalm_code/blob/master/jinja_helper.py
Connect with me https://bigevilbeard.github.io
