A modern Python CLI tool for generating network device configurations using CSV data and Jinja2 templates.
- 🚀 Modern CLI interface with rich terminal output
- 📝 Generate individual configuration files per device
- 📊 CSV-based variable management
- 🎨 Jinja2 templating support
- 📁 Automatic output directory management
- 📋 Single-file output option with timestamp
- ✨ Progress tracking and error handling
python >= 3.7
rich >= 13.9.4
typer >= 0.15.1
pandas >= 2.2.3
Jinja2 >= 3.1.5
- Clone the repository:
git clone https://github.com/yourusername/netfig.git
cd netfig
- Install dependencies:
pip install -r requirements.txt
python netfig.py <csv_file> <template_file>
python netfig.py <csv_file> <template_file> --output <directory_name>
python netfig.py variables.csv templates/cisco_template.j2 --output my_configs
python netfig.py --help
netfig/
├── input/ # Place your CSV files here
├── templates/ # Store your Jinja2 templates
├── output/ # Generated configurations
├── utils/ # Utility functions
├── netfig.py # Main application
└── requirements.txt
Your CSV file should contain variables for your templates. The first column's values will be used as filenames for individual configurations.
Example variables.csv
:
hostname,interface,ip_address,subnet_mask
ROUTER01,GigabitEthernet0/1,192.168.1.1,255.255.255.0
ROUTER02,GigabitEthernet0/1,192.168.1.2,255.255.255.0
Use standard Jinja2 template syntax. Variables from CSV columns can be referenced directly.
Example cisco_template.j2
:
hostname {{ hostname }}
!
interface {{ interface }}
ip address {{ ip_address }} {{ subnet_mask }}
no shutdown
!
The script generates:
- Individual
.txt
files for each row in your CSV (named after the first column) - A timestamped single file containing all configurations