NetAuto Academy

Production Automation

Capstone: A Staged, Gated Production Rollout

Advanced17 min read

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
🎓 Teach This Lesson

Listen to a guided explanation of this lesson.

Spoken narration isn't supported in this browser.

Both outcomes, not just the happy one

  1. Reviewed changeassumed complete -- Git/NetDevOps, Lesson 1
  2. select_canary(nr)Lesson 2
  3. run_stage(canary)apply + validate -- Lesson 3
  4. evaluate_gate(result, threshold)Lesson 3
  5. PASS -> run_stage(rest) | FAIL -> rollback_stage(canary)Lesson 4
  6. 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.

Quick checkConcept check
Why does this capstone execute two separate scenarios instead of just demonstrating a successful rollout?

The full orchestrator

run_rollout(nr, threshold) -- real, composed from Lessons 2-4
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 report

Every 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.

Quick checkIdentify the correct code
Which line in run_rollout() is the actual 'gate' this entire module is named after?

Real, verified run — Scenario A: canary passes, rollout expands

real, executed
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.

output — real, verified
{
"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.

Quick checkPredict output
In Scenario A's real, verified report, why does 'expanded' contain four hosts (SW2-SW5) and not five?

Real, verified run — Scenario B: canary fails, rollout aborts and rolls back

real, executed
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.

output — real, verified
{
"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.

Quick checkScenario
How does this lesson prove that SW2-SW5 were genuinely never touched in Scenario B, rather than just assuming it from reading the code?

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.

Quick checkScenario
How should a learner honestly describe what this capstone proves?

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.