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...
Any other Python method I should consider here? Thanks.
Solved! Go to Solution.
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.
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.
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?
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide