On-Call Runbook Executor
When to invoke
- "Run the database failover runbook."
- "Walk me through the certificate rotation playbook."
- "Execute the deploy rollback steps."
Inputs needed
- Runbook YAML — see schema below.
- Mode —
dry-run(default; prints commands) orexecute(runs them). - Approval prompts — interactive
--confirmprompt before each action by default.
Runbook schema
name: deploy-rollback
description: Roll back the most recent deploy of svc-checkout
owner: sre-oncall
prechecks:
- desc: kubectl is configured
cmd: kubectl version --client --output=yaml
steps:
- id: identify_revision
desc: Identify the previous revision
cmd: kubectl rollout history deploy/svc-checkout | tail -3
expect_zero_exit: true
- id: rollback
desc: Roll back to the previous revision
cmd: kubectl rollout undo deploy/svc-checkout
requires_confirm: true
- id: verify
desc: Wait for rollout to complete
cmd: kubectl rollout status deploy/svc-checkout --timeout=120s
expect_zero_exit: true
postchecks:
- desc: 5xx is back to baseline
cmd: ./scripts/check_5xx.sh
Workflow
- Load the runbook YAML.
- Run prechecks — abort if any precheck fails.
- For each step:
- Print step description and command.
- In
executemode and ifrequires_confirm, prompt the operator. - Run command, capture stdout/stderr/exit.
- Compare to expectation; mark pass/fail.
- Run postchecks.
- Emit a Markdown execution log (timestamps, exit codes, outputs).
Guardrails
- Default mode is
dry-run; require an explicit--mode executeto run anything. - Steps with
requires_confirm: truemust prompt unless--yesis set. - Never auto-skip a failed precheck — abort and surface clearly.
- Truncate captured output to a configurable max bytes per step.
Reference code
runbook.py reads YAML, executes locally, and writes a Markdown log.