This project provides an automated network validation pipeline powered by Batfish, Ansible, and GitHub Actions. It supports customizable configuration tests, ensuring that all network configs are validated, verified, and safely backed up. The project also supports generating device configurations using Jinja2 templates.
Clone this repository, create a Personal Access Token (PAT) in GitHub Developer Settings, then add a repository secret named "GH-PAT" and paste your PAT there.
To start validating with the basic test, push any ".cfg" file into:
snapshots/ci_net/s1/configs/manual
Or push a ".yaml" file for Jinja2 autogeneration into:
snapshots/ci_net/s1/device-yaml/
⚠️ Note: This project includes a basic default test, but for the best results you should create and customize your own validation tests.
On config push, the CI pipeline steps:
- Downloads and starts Batfish in Docker
- Sets up Python 3.11
- Installs pybatfish (2025.7.7.2423), Ansible, PyTest, and Jinja2
- Prepares Batfish directories
- Generates configs from YAML (if present)
- Ensure Batfish snapshot folder exists (Ansible)
- Runs PyTest validation
- Creates backup of generated configs (on success)
- Commits and pushes backups to the repo (on success)
Out of the box, the project supports generating configs from YAML for Cisco, Juniper, and Palo Alto Networks. In fact, the project supports all vendors supported by batfish but configuration generation is manual except for the three vendors mentioned above. But you can create your own jinja2 template for config generation.
This project includes many directories, structured as illustrated below:
NetOps/
├── .github/
│ └── workflows/
│ └── workflow.yml
│
├── ansible/
│ ├── hosts
│ └── playbook.yml
│
├── snapshots/
│ └── ci_net/
│ └── s1/
│ ├── configs/
│ │ ├── manual/
│ │ │ └── *.cfg
│ │ └──generated/
│ │ └── *.cfg
│ └── device-yaml/
│ └── *.yaml
│
├── tests/
│ └── test_batfish.py
│
├── tools/
│ ├── templates/
│ │ └── *.j2
│ ├── conf-generator.py
│ └── render_config.py
│
├── backup/ <-- Backup storage for validated configs
│ └── *.cfg
│
│
├── README.md
└── LICENSE