How ayoubchkur/ansible-bgp-validation-lab works
Project type and purpose
• This is a network-automation and validation tool that builds, configures and tests a multi-AS BGP/OSPF topology in PNETLab using Cisco IOL images.
• It combines Infrastructure as Code (Ansible, Jinja2), network device APIs (NAPALM/Netmiko), a network simulator (PNETLab/Cisco IOL), a validation engine (Batfish/pybatfish) and CI/CD (GitHub Actions).
File structure
• Top-level files only:
• .gitignore – standard VCS ignore rules
• README.md – full description of tools and workflow
• No subdirectories in the tree, but README mentions components that live conceptually in the repo (Ansible playbooks & roles, Jinja2 templates, Batfish tests, CI workflow).
README for additional insights
• Tools Used: PNETLab, Cisco IOL, Ansible, Jinja2, NAPALM/Netmiko, Batfish, GitHub Actions
• Features section outlines the workflow: render configs → push to devices or export for simulator → load into Batfish → run validation → CI/CD pipeline triggers on code change.
Main components
a. Version Control & CI Layer
• GitHub repo (Ansible playbooks, Jinja2 templates, Batfish test definitions)
• GitHub Actions runner (CI pipeline that kicks off validation jobs on push)
b. Config Generation & Deployment Layer
• Ansible controller with Jinja2 engine
• Optional NAPALM / Netmiko connectors for direct device push
• Generated startup-config artifacts for PNETLab import
c. Simulation & Test Environment
• PNETLab instance hosting Cisco IOL routers (multi-AS BGP/OSPF topology)
• Batfish container (with pybatfish) that ingests device configs and sim state
d. Validation & Reporting
• Batfish-driven checks: BGP session health, route leakage tests
• CI status reports back to GitHub
e. Developer Workstation (optional)
• Local testing of playbooks or manual invocation of Batfish before push
Relationships and interactions
• Developer pushes code → GitHub repo
• GitHub Actions clone repo → run Ansible playbooks + Jinja2 → generate configs
• Ansible either:
• Uses NAPALM/Netmiko to push directly into real/simulated devices OR
• Exports config files that PNETLab imports into IOL routers
• After config load, GitHub Actions spins up Batfish container → loads the same configs → runs pybatfish tests
• Test results (pass/fail, routing table snapshots) flow back to GitHub Actions → developer sees CI status
Architectural patterns and principles
• Separation of concerns:
• IaC (Ansible + Jinja2) vs. validation (Batfish) vs. orchestration (CI) vs. simulation (PNETLab)
• Declarative config pipelines, idempotent playbooks
• Continuous validation ensures network invariants are met on every change
• Modular test definitions in Batfish, reusable Jinja2 network templates