Production Automation
Capstone: A Staged, Gated Production Rollout
What you'll learn
- Combining canary selection, staging, gating, and rollback into one script
- Why demonstrating only the success path would be dishonest here
- Reading two real, verified end-to-end runs and their reports
- What this module never claims, and why
Listen to a guided explanation of this lesson.
Spoken narration isn't supported in this browser.
Both outcomes, not just the happy one
- Reviewed changeassumed complete -- Git/NetDevOps, Lesson 1
- select_canary(nr)Lesson 2
- run_stage(canary)apply + validate -- Lesson 3
- evaluate_gate(result, threshold)Lesson 3
- PASS -> run_stage(rest) | FAIL -> rollback_stage(canary)Lesson 4
- report
This capstone runs twice, for real, on purpose
A capstone that only shows a successful rollout would overstate what this module actually verified. Both real fixture scenarios from Lessons 3-4 are run here, end to end, producing two genuinely different reports.
The full orchestrator
def run_rollout(nr, threshold=1.0):
canary, rest = select_canary(nr)
canary_result = run_stage(canary)
gate = evaluate_gate(canary_result, threshold=threshold)
report = {
"canary": canary_result,
"gate": gate,
"expanded": {},
"rolled_back": False,
}
if gate["decision"] == "PASS":
rest_result = run_stage(rest)
report["expanded"] = rest_result
else:
rollback_agg = rollback_stage(canary)
report["rolled_back"] = not rollback_agg.failed
return reportEvery function here is exactly what Lessons 2-4 already verified -- select_canary, run_stage, evaluate_gate, rollback_stage. This orchestrator introduces no new mechanism, only the if/else connecting them.
Real, verified run — Scenario A: canary passes, rollout expands
nr = load_inventory("inventory/hosts_pass.yaml")
report = run_rollout(nr, threshold=1.0)
print(json.dumps(report, indent=2))The exact fleet and fixtures from Lesson 3's PASS-path example.
{
"canary": {
"SW1": { "applied": true, "validated": true, "detail": "description='mgmt-uplink-verified'" }
},
"gate": { "decision": "PASS", "pass_rate": 1.0, "passed": 1, "total": 1 },
"expanded": {
"SW2": { "applied": true, "validated": true, "detail": "description='mgmt-uplink-verified'" },
"SW3": { "applied": true, "validated": true, "detail": "description='mgmt-uplink-verified'" },
"SW4": { "applied": true, "validated": true, "detail": "description='mgmt-uplink-verified'" },
"SW5": { "applied": true, "validated": true, "detail": "description='mgmt-uplink-verified'" }
},
"rolled_back": false
}Real, verified output. The canary passed, the gate opened, and the change genuinely expanded to all four remaining hosts -- no rollback needed.
Real, verified run — Scenario B: canary fails, rollout aborts and rolls back
nr = load_inventory("inventory/hosts_fail.yaml")
report = run_rollout(nr, threshold=1.0)
print(json.dumps(report, indent=2))A genuinely different fixture set -- the canary's commit succeeds but its validation fails, exactly as Lessons 3-4 verified in isolation. Note: no fixture files exist for SW2-SW5 in this scenario -- if expansion were ever mistakenly triggered, it would fail loudly rather than silently succeed.
{
"canary": {
"SW1": { "applied": true, "validated": false, "detail": "description='mgmt-uplink'" }
},
"gate": { "decision": "FAIL", "pass_rate": 0.0, "passed": 0, "total": 1 },
"expanded": {},
"rolled_back": true
}Real, verified output. The canary's change didn't take effect, the gate correctly aborted, 'expanded' is genuinely empty (the rest of the fleet was never touched -- confirmed by the absence of any error, since no fixtures exist for those hosts in this scenario), and rollback succeeded.
What this capstone never claims
Mock/offline execution -- always labeled as such
Every result on this page came from NAPALM's real mock driver -- the same mechanism verified in NAPALM for Network Engineers (Phase 3.5) and reused in every capstone since. This is genuinely executed, local, offline automation logic (Category A). It is never a real production rollout, real hardware verification, or live fleet validation -- no such infrastructure was used or is claimed anywhere in this module.
Key takeaways
- This capstone combines every piece of the module -- canary selection, apply-then-validate staging, threshold gating, and rollback -- into one orchestrator that introduces no new mechanism of its own beyond the if/else connecting them.
- Real, verified Scenario A: canary passes (100% rate), rollout genuinely expands to the remaining four hosts, no rollback.
- Real, verified Scenario B: canary's commit succeeds but validation fails, the gate correctly aborts, the rest of the fleet is provably untouched, and rollback genuinely succeeds.
- Both outcomes were executed for real -- this module never demonstrates only the success path.
- Every result here is Category A (genuine, local, mock-driver execution) -- never presented as a real production rollout, real hardware verification, or live fleet validation.