| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project demonstrates how I built an automated network configuration system for a simulated multi-router VyOS lab.
The goal was to move away from manual CLI work and adopt modern infrastructure-as-code practices:
network-automation-python/
├── README.md # Project documentation (this file)
├── .env.example # Example environment variables (copy to .env)
├── inventory/ # YAML inventory (device definitions, ASNs, IPs)
│ └── lab.yml
├── templates/ # Jinja2 templates (base, OSPF, BGP)
│ ├── base_vyos.j2
│ ├── ospf_vyos.j2
│ └── bgp_vyos.j2
├── configs/ # Static sample configs (if needed)
├── configs_generated/ # Auto-generated configs (gitignored)
├── backups/ # Device backups with timestamp (gitignored)
├── logs/ # Rotating logs + per-device validation output
├── scripts/ # Python automation scripts
│ ├── common.py
│ ├── deploy_async.py
│ ├── diff.py
│ ├── backup.py
│ ├── validate.py
│ ├── cleanup.py
│ └── logging_config.py
└── .github/workflows/ci.yml # CI/CD pipeline (lint + config build)cp .env.example .envThe network automation process is divided into a clear, six-step workflow:
Generate Configs
python scripts/deploy_async.py --generate-onlyThis script generates .set configuration files in the configs_generated/ directory, pulling data from an inventory and applying it to predefined templates.
Compare Intended vs. Running Configs
python scripts/diff.pyThis command shows a line-by-line comparison between the newly generated configurations and the configurations currently active on the network devices, allowing for a clear "what-if" analysis before deployment.
Take Backups
python scripts/backup.pyBefore any changes are pushed, this script takes a backup of the current device configurations, saving them to the backups/ directory with a timestamp. This provides a critical safety net for easy rollback.
Deploy Changes (Parallel & Idempotent)
python scripts/deploy_async.py --max-workers 6This is the core deployment script. It connects to each router and pushes only the missing commands, making the operation idempotent. It supports concurrent connections with a configurable number of workers for faster deployment across multiple devices.
Validate Post-Deploy
python scripts/validate.pyAfter deployment, this script verifies that the intended state has been achieved by checking for OSPF adjacencies, BGP sessions, and default routes.
Cleanup Old Logs/Backups
python scripts/cleanup.pyThis script helps maintain a tidy repository by removing old log files and backups that are older than the retention period defined in the .env file.
This project is integrated with GitHub Actions to automate key tasks on every push or pull request:
This project is licensed under the MIT License. Feel free to use it as a reference or template for your own projects. Attribution is appreciated.
| Back | FazBrowse Home | New Git URL |