This program reads in the configuration file from a Cisco router or switch running IOS-XE extracts the unique
information and inserts it into a new configuration at designated locations.This new configuration is then rendered with a Jinja template with site specific configuration parameters and a
golden configuration Jinja template that consists of best practice configurations standard across all site.
This program was developed to meet the need to upgrade switch configurations during platform upgrades using the latest
industry best practices and enterprise security standards in an automated fashion.
!!![config_name]!!!
.
!!!Interfaces
is used to designate where the interface configuration goes.[Step 1] Clone repo:
git clone git@github.com:jconwell3115/Golden_Config_Generator.git
[Step 2] Navigate to the project directory
cd Golden_Config_Generator
[Step 3] Install required dependencies:
pip install -r requirements.txt
[Step 4] (Optional) Install pre-commit:
pre-commit install
(GoldenConfigGenerator) jconw483@Jons-PC ~/Work_Environments/GoldenConfigGenerator/Golden_Config_Generator $ python3 golden_config_generator.py -h
usage: golden_config_generator.py [-h] [-c CONFIG]
This program reads in an old configuration file and then converts it to a new 'golden'
configuration using industry standard best practices for Cisco Catalyst switches running
IOS-XE versions 16.9 and up.
options:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
Configuration file to convert
Thanks for using golden_config_generator!
This program can be ran with the
-c {{ switch_config }}
or with no argument. If run
with no
argument the program will ask for the name of the switch configurationFuture release will include the option to convert all configurations in a given
directory.
Run the program on the test configurations for proof of concept:
Sample configurations files are located in the configuration_files/old_configurations
directory.
(.venv) $ golden_config_generator.py -c S1-AS-3320-104-1.cfg
This will output the new configurations in the configuration_files/new_configurations
directory.
There will be a template rendered with the {{ hostname }}.j2
located in the
templates/new_switch_templates
directory
.
├── configuration_files
│ ├── new_configurations
│ │ ├── S1-AS-3320-104-1_2025_03_14.cfg
│ │ └── S3-CS-2015-321-1_2025_03_14.cfg
│ └── old_configurations
│ ├── S1-AS-3320-104-1.cfg
│ ├── S2-AS-527-109-1.cfg
│ └── S3-CS-2015-321-1.cfg
├── golden_config_generator.py
├── LICENSE
├── pipdeptree_current.txt
├── pyproject.toml
├── README.md
├── requirements.txt
└── templates
├── new_switch_templates
│ ├── S1-AS-3320-104-1.j2
│ └── S3-CS-2015-321-1.j2
├── site_1.j2
├── site_2.j2
├── site_3.j2
└── switch_template.j2
configuration_files - Directory to store old and new configurations
templates - Directory that stores the site specific templates and the base
golden config switch template
This is a general idea and the details would need to be defined a bit more
Create Ansible Playbook that orchestrates the following
Email:
jconwell3115@gmail.com
Phone: 867-5309
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use.
You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.
Owner
Contributors
Categories
NetworkingToolsProducts
Catalyst SwitchesCatalyst RoutersIOS XEProgramming Languages
JinjaLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community