Content
# Network CI/CD Lab
Cisco CML-based network lab with full CI/CD pipeline using Ansible, pyATS, GitHub Actions, and GitLab CI.
## Labs
| Lab | ID | OOB Range | Purpose |
|-----|----|-----------|---------|
| PROD | `7148e855-6c7e-458a-a649-c5f4ccacf4fa` | 172.30.1.x/22 | Pipeline validation target |
| DEV | `f9c13319-e511-4df8-a709-7e472a13d74d` | 172.30.2.x/22 | Active development |
## Quick Start
```bash
# Install dependencies
pip install ansible pyats genie
ansible-galaxy collection install -r ansible/collections/requirements.yml
# After starting CML labs — apply ISSUE-001 fix to MGMT switches
./scripts/lab-startup.sh all
# Run full pipeline against DEV
ansible-playbook ansible/playbooks/pipeline.yml -i ansible/inventory/dev.yml \
-e vault_device_password=admin123 -e vault_enable_password=admin123 \
-e vault_dev_snmp_ro=devread -e vault_dev_snmp_rw=devwrite
# Run validation only
ansible-playbook ansible/playbooks/validate.yml -i ansible/inventory/dev.yml \
-e vault_device_password=admin123 -e vault_enable_password=admin123 \
-e vault_dev_snmp_ro=devread -e vault_dev_snmp_rw=devwrite
# Run pyATS tests
pyats run job tests/pyats/network_tests.py --testbed tests/pyats/testbed.yaml
```
## Repository Structure
```
.
├── .github/
│ └── workflows/
│ └── network-cicd.yml GitHub Actions pipeline
├── ansible/
│ ├── ansible.cfg
│ ├── collections/
│ │ └── requirements.yml cisco.ios, ansible.netcommon
│ ├── inventory/
│ │ ├── prod.yml PROD device inventory
│ │ ├── dev.yml DEV device inventory
│ │ └── group_vars/
│ │ ├── all/
│ │ │ ├── main.yml Common variables
│ │ │ └── vault.yml Credentials (encrypt with ansible-vault)
│ │ ├── prod/main.yml PROD-specific variables
│ │ └── dev/main.yml DEV-specific variables
│ ├── playbooks/
│ │ ├── deploy.yml Full deployment
│ │ ├── validate.yml Validation only
│ │ ├── oob_fix.yml ISSUE-001 remediation
│ │ └── pipeline.yml Full CI/CD sequence
│ └── roles/
│ ├── baseline/ Hostname, NTP, SNMP, SSH, logging
│ ├── oob_fix/ ISSUE-001 auto-remediation
│ ├── security/ ACLs, VTY hardening
│ ├── interfaces/ Interface configuration
│ ├── routing/ OSPF, static routes, STP, DHCP snooping
│ └── validate/ All validation checks incl. ISSUE-001
├── gitlab/
│ └── .gitlab-ci.yml GitLab CI pipeline (copy to repo root)
├── tests/
│ └── pyats/
│ ├── testbed.yaml pyATS device testbed
│ └── network_tests.py Test suite
├── docs/
│ └── known-issues.md ISSUE-001, ISSUE-002 documentation
├── scripts/
│ └── lab-startup.sh Post-boot ISSUE-001 fix helper
└── topologies/
├── PROD-Network-Lab.yaml CML topology export
└── DEV-Network-Lab.yaml CML topology export
```
## Pipeline Flow
```
feature/* or dev/* branch push
│
▼
┌─────────┐
│ lint │ yamllint + ansible-lint + syntax-check
└────┬────┘
│
▼
┌──────────┐
│ oob_fix │ ISSUE-001 remediation on MGMT switches
└────┬─────┘
│
▼
┌───────────┐
│ pre_check │ Validate current state (non-blocking)
└─────┬─────┘
│
▼
┌────────┐
│ deploy │ baseline → security → interfaces → routing
└────┬───┘
│
▼
┌──────────────┐
│ post_validate│ Ansible validate + pyATS tests
└──────────────┘
│
│ (on merge to main — manual approval)
▼
┌──────────────┐
│ PROD deploy │ Same sequence, manual gates
└──────────────┘
```
## Known Issues
See [docs/known-issues.md](docs/known-issues.md).
**ISSUE-001 — MGMT Switch Vlan99 SVI Down:** Both `PROD-MGMT-SW` and `DEV-MGMT-SW` require manual `ip routing` to be applied after every fresh boot. The `oob_fix` role and `oob_fix.yml` playbook automate this. Always run `lab-startup.sh` after starting the CML labs.
## GitHub Setup
1. Add repository secrets: `DEVICE_PASSWORD`, `ENABLE_PASSWORD`, `PROD_SNMP_RO`, `PROD_SNMP_RW`, `DEV_SNMP_RO`, `DEV_SNMP_RW`
2. Create environments `dev` and `prod` in Settings → Environments
3. Add required reviewer to `prod` environment for manual approval gate
4. Ensure your GitHub Actions runner has network access to `172.30.x.x`
## GitLab Setup
1. Copy `gitlab/.gitlab-ci.yml` to repo root as `.gitlab-ci.yml`
2. Add CI/CD variables in Settings → CI/CD → Variables: same set as GitHub secrets
3. Register a GitLab Runner with tag `network-lab` and network access to `172.30.x.x`
## Device Credentials
| Field | Value |
|-------|-------|
| Username | admin |
| Password | admin123 |
| Enable | admin123 |
| PROD SNMP RO | prodread |
| DEV SNMP RO | devread |