A Python-based network automation framework for managing and configuring network devices at scale. Automate backups, deployments, and provisioning across multi-vendor environments.
Check out our latest additions:
See NEW_FEATURES.md for complete setup instructions!
- Features
- Demo
- Installation
- Quick Start
- Usage
- Configuration
- Examples
- Project Structure
- Security
- Roadmap
- Contributing
- License
| Feature | Description |
|---|---|
| 🔄 Automated Backups | Schedule and execute configuration backups with timestamps |
| 📝 Template Engine | Jinja2-powered configuration templates for standardized deployments |
| 🔌 Multi-Vendor | Support for Cisco, Juniper, Arista, HP, and 50+ vendors via Netmiko |
| 📊 Comprehensive Logging | Detailed audit trails for compliance and troubleshooting |
| ⏮️ Rollback Support | One-command rollback to previous configurations |
| 🎯 Batch Operations | Execute commands across multiple devices simultaneously |
| 🔐 Secure by Design | Credential management best practices built-in |
| 🛠️ Easy Configuration | Simple YAML-based device inventory |
The framework follows a modular architecture for flexibility and maintainability:
graph TB
subgraph User["👤 Network Engineer"]
CLI[Command Line Interface]
end
subgraph Framework["🐍 Network Automation Framework"]
subgraph Core["Core Modules"]
DM[Device Manager<br/>Connection Handler]
end
subgraph Features["Features"]
Backup[Config Backup<br/>Module]
Deploy[Config Deploy<br/>Module]
end
subgraph Storage["Storage & Templates"]
Templates[Jinja2 Templates<br/>config/templates/]
BackupDir[Backup Storage<br/>backups/]
Logs[Logs<br/>logs/]
end
end
subgraph Devices["🌐 Network Infrastructure"]
R1[Router 1<br/>Cisco IOS]
R2[Router 2<br/>Cisco IOS]
SW1[Switch 1<br/>Arista EOS]
SW2[Switch 2<br/>Juniper]
FW[Firewall<br/>Palo Alto]
end
subgraph Config["⚙️ Configuration"]
YAML[devices.yaml<br/>Device Inventory]
end
CLI -->|Run Scripts| Backup
CLI -->|Run Scripts| Deploy
Backup --> DM
Deploy --> DM
DM -->|SSH/Netmiko| R1
DM -->|SSH/Netmiko| R2
DM -->|SSH/Netmiko| SW1
DM -->|SSH/Netmiko| SW2
DM -->|SSH/Netmiko| FW
Backup -->|Save configs| BackupDir
Deploy -->|Load templates| Templates
DM -->|Write logs| Logs
YAML -.->|Device Info| DM
Templates -.->|Config Templates| Deploy
style Framework fill:#e1f5ff
style Devices fill:#fff4e1
style Config fill:#f0f0f0
style User fill:#e8f5e9
Key Components:
- Device Manager: Handles SSH connections via Netmiko
- Backup Module: Automated configuration backups with timestamps
- Deploy Module: Template-based configuration deployment
- Storage Layer: Organized backup storage and Jinja2 templates
# Backup all devices
$ python scripts/config_backup.py
[INFO] Connecting to 192.168.1.1
[INFO] Successfully connected to 192.168.1.1
[INFO] Backup saved: backups/192.168.1.1_20240115_143022.txt
[INFO] ✓ 5 devices backed up successfully
# Deploy configuration template
$ python scripts/config_deploy.py --template interface_config.j2 \
--vars '{"interface_name": "GigabitEthernet0/1", "vlan": 10}'
[INFO] Configuration deployed to 192.168.1.1
[INFO] ✓ Deployment successful- Python 3.7 or higher
- SSH access to network devices
- Valid device credentials
# Clone the repository
git clone https://github.com/yourusername/network-automation-framework.git
cd network-automation-framework
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create required directories
mkdir -p backups logs config/templates- Configure your devices in
config/devices.yaml:
devices:
- device_type: cisco_ios
host: 192.168.1.1
username: admin
password: your_password
port: 22- Run your first backup:
python scripts/config_backup.py- Deploy a configuration:
python scripts/config_deploy.py --host 192.168.1.1 \
--commands "ntp server 10.0.0.1"📖 See QUICKSTART.md for detailed instructions.
# Backup all devices
python scripts/config_backup.py
# Custom backup directory
python scripts/config_backup.py --backup-dir /path/to/backups
# Specific devices file
python scripts/config_backup.py --devices config/prod_devices.yaml# Deploy specific commands
python scripts/config_deploy.py --commands \
"interface GigabitEthernet0/1" \
"description Uplink to Core"
# Deploy to specific device
python scripts/config_deploy.py --host 192.168.1.1 \
--file config/my_config.txt
# Use template with variables
python scripts/config_deploy.py --template interface_config.j2 \
--vars '{"interface_name": "Gi0/1", "vlan": 100}'python scripts/config_deploy.py --host 192.168.1.1 \
--file backups/192.168.1.1_20240115_143022.txtdevices:
- device_type: cisco_ios
host: 192.168.1.1
username: admin
password: secure_password
secret: enable_password # Optional
port: 22
- device_type: juniper_junos
host: 192.168.1.10
username: netadmin
password: secure_password
port: 22Click to expand supported platforms
- Cisco:
cisco_ios,cisco_nxos,cisco_xr,cisco_asa - Juniper:
juniper_junos - Arista:
arista_eos - HP:
hp_procurve,hp_comware - Dell:
dell_force10,dell_os10 - Palo Alto:
paloalto_panos - And 40+ more via Netmiko
Create config/templates/bulk_interface.j2:
{% for interface in interfaces %}
interface {{ interface.name }}
description {{ interface.description }}
switchport access vlan {{ interface.vlan }}
no shutdown
{% endfor %}Deploy:
python scripts/config_deploy.py --template bulk_interface.j2 \
--vars '{"interfaces": [
{"name": "Gi0/1", "description": "Workstation", "vlan": 10},
{"name": "Gi0/2", "description": "Printer", "vlan": 20}
]}'from scripts.device_manager import DeviceManager
from scripts.config_backup import ConfigBackup
# Backup a device programmatically
device_config = {
'device_type': 'cisco_ios',
'host': '192.168.1.1',
'username': 'admin',
'password': 'password'
}
backup_manager = ConfigBackup()
backup_manager.backup_device(device_config)More examples in examples/example_usage.py
network-automation-framework/
├── 📄 README.md # This file
├── 📄 QUICKSTART.md # Quick start guide
├── 📄 requirements.txt # Python dependencies
├── 📄 .gitignore # Git ignore rules
│
├── 📂 config/
│ ├── 📄 devices.yaml # Device inventory
│ └── 📂 templates/ # Jinja2 templates
│ └── 📄 interface_config.j2
│
├── 📂 scripts/
│ ├── 📄 __init__.py
│ ├── 📄 device_manager.py # Core device connections
│ ├── 📄 config_backup.py # Backup functionality
│ └── 📄 config_deploy.py # Deployment functionality
│
├── 📂 examples/
│ └── 📄 example_usage.py # Usage examples
│
├── 📂 backups/ # Configuration backups
└── 📂 logs/ # Application logs
- ✅ Credentials stored in YAML (excluded from Git)
- ✅ Comprehensive logging for audit trails
- ✅ SSH-based authentication
- ✅ No hardcoded passwords in code
- ✅ File permission recommendations
# Restrict permissions on sensitive files
chmod 600 config/devices.yaml
# Use environment variables for credentials
export DEVICE_PASSWORD='your_password'
# Consider using SSH keys instead of passwords
⚠️ Warning: Never commitconfig/devices.yamlto version control!
- 🌐 Web-based dashboard for monitoring
- ✅ Configuration compliance checking
- ⏰ Scheduled backup jobs (cron integration)
- 🔄 Git integration for version control
- 📡 REST API for remote operations
- 🔍 Configuration diff and change tracking
- ⚡ Multi-threading for faster operations
- 📊 Reporting and analytics dashboard
Contributions are welcome! Here's how you can help:
- 🍴 Fork the repository
- 🌟 Create a feature branch (
git checkout -b feature/AmazingFeature) - 💾 Commit your changes (
git commit -m 'Add some AmazingFeature') - 📤 Push to the branch (
git push origin feature/AmazingFeature) - 🎉 Open a Pull Request
Please read CONTRIBUTING.md for details on our code of conduct.
Your Name
- GitHub: @careed23
- LinkedIn: Your LinkedIn
- Email: careed23@outlook.com
Made with ❤️ for Network Engineers
⭐ Star this repo if you find it helpful!