Operational Runbook¶
This runbook covers the day-2 operational procedures for the deterministic documentation platform. It is the DevOps team's first reference for incidents, deployments, and routine maintenance.
Principle
Every procedure in this runbook is executable from the Docker toolchain image — no host tool installation required.
Quick Reference¶
| Action | Command |
|---|---|
| Run full doc pipeline locally | docker run --rm -v "$(pwd)":/workspace dtds-example scripts/generate-docs.sh |
| Serve docs locally | docker run --rm -p 8000:8000 -v "$(pwd)":/workspace dtds-example mkdocs serve -f example/mkdocs.yml --dev-addr 0.0.0.0:8000 |
| Run OPA policy tests | docker run --rm -v "$(pwd)":/workspace dtds-example opa test example/policies/terraform/ -v |
| Run Pester DSC tests | docker run --rm -v "$(pwd)":/workspace dtds-example pwsh -Command "Invoke-Pester example/dsc/tests/ -Output Detailed" |
| Validate Terraform | docker run --rm -v "$(pwd)":/workspace dtds-example bash -c "cd example/terraform && terraform init && terraform validate" |
| Generate DSC docs | docker run --rm -v "$(pwd)":/workspace dtds-example pwsh -File example/dsc/build.ps1 |
CI/CD Pipeline Operations¶
Re-triggering a Failed Pipeline¶
# Manually trigger the workflow (requires gh CLI)
gh workflow run docs-pipeline.yml --ref main
# Or push an empty commit to re-trigger on push
git commit --allow-empty -m "chore: re-trigger pipeline"
git push
Viewing Pipeline Logs¶
# List recent workflow runs
gh run list --workflow docs-pipeline.yml --limit 10
# View logs for a specific run
gh run view <RUN_ID> --log
Incident Response¶
The following flowchart covers the most common failure scenarios.
flowchart TD
START([🚨 Alert: Pipeline Failed]) --> IDENTIFY{Which job failed?}
IDENTIFY -->|opa-tests| OPA_FAIL[OPA unit test failure]
IDENTIFY -->|dsc-tests| DSC_FAIL[Pester test failure]
IDENTIFY -->|terraform| TF_FAIL[Terraform or OPA gate failure]
IDENTIFY -->|drift-check| DRIFT_FAIL[Infrastructure drift detected]
IDENTIFY -->|docs-build| DOCS_FAIL[Documentation build failure]
IDENTIFY -->|docs-publish| PUB_FAIL[GitHub Pages deploy failure]
OPA_FAIL --> OPA_STEPS["1. Run: opa test policies/terraform/ -v\n2. Identify failing test\n3. Fix policy or test\n4. Push fix"]
DSC_FAIL --> DSC_STEPS["1. Run: Invoke-Pester dsc/tests/ -Output Detailed\n2. Identify failing test\n3. Check DTDS_FileContent.psm1\n4. Push fix"]
TF_FAIL --> TF_TYPE{Error type?}
TF_TYPE -->|validate error| TF_SYNTAX["Fix HCL syntax in terraform/\nRun: terraform validate"]
TF_TYPE -->|OPA deny| TF_POLICY["Policy violated:\n1. Read denial message\n2. Fix the resource in terraform/\n OR\n3. Update OPA policy if rule is wrong\n4. Run: opa test policies/ -v first"]
TF_TYPE -->|plan error| TF_PROVIDER["Provider or dependency error:\n1. Check terraform init output\n2. Check provider versions in main.tf\n3. Run: terraform init -upgrade"]
DOCS_FAIL --> DOCS_TYPE{Error type?}
DOCS_TYPE -->|mkdocs build| MKDOCS_ERR["1. Run: mkdocs build --config-file example/mkdocs.yml --strict\n2. Check for broken links or missing files\n3. Fix referenced pages in mkdocs.yml nav"]
DOCS_TYPE -->|terraform-docs| TFDOCS_ERR["1. Check terraform-docs version\n2. Confirm output-file path exists\n3. Run: terraform-docs markdown table example/terraform/"]
DOCS_TYPE -->|ansible| ANSIBLE_ERR["1. Check inventory.yml is valid\n2. Run: ansible-playbook -i ansible/inventory.yml ansible/playbook.yml --check"]
PUB_FAIL --> PUB_STEPS["1. Check GitHub Pages is enabled\n (repo Settings → Pages → Source: GitHub Actions)\n2. Check GITHUB_TOKEN permissions\n (repo Settings → Actions → Workflow permissions: Read and write)\n3. Re-run the docs-publish job only"]
DRIFT_FAIL --> DRIFT_STEPS["See: Responding to Infrastructure Drift (ADR-0024) below"]
OPA_STEPS --> RESOLVED([✅ Resolved])
DSC_STEPS --> RESOLVED
TF_SYNTAX --> RESOLVED
TF_POLICY --> RESOLVED
TF_PROVIDER --> RESOLVED
MKDOCS_ERR --> RESOLVED
TFDOCS_ERR --> RESOLVED
ANSIBLE_ERR --> RESOLVED
PUB_STEPS --> RESOLVED
DRIFT_STEPS --> RESOLVED
Routine Maintenance Procedures¶
Updating Tool Versions¶
All tool versions are pinned in the Dockerfile. To upgrade:
- Update the
ARGvalue inexample/Dockerfile - Build and test locally:
docker build -t dtds-example example/ - Run the smoke test:
docker run --rm dtds-example(prints tool versions) - Run the full pipeline:
docker run --rm -v "$(pwd)":/workspace dtds-example scripts/generate-docs.sh - Update the version references in
docs/architecture/index.md(technology radar) - Open a PR with
chore: bump <tool> to <version>
Adding a New OPA Policy¶
- Create
policies/terraform/deny_<name>.regousingimport rego.v1 - Set
__rego__metadoc__withrelated_adr,related_requirements, andcompliancefields - Create
policies/terraform/deny_<name>_test.regowith 100% rule coverage - Run
opa test policies/terraform/ -v— all tests must pass - Add the policy to
docs/compliance/opa-policies.md - Add the policy to the security controls matrix in
docs/security/index.md - Update
docs/requirements/moscow.mdif a new requirement is being implemented - Update
docs/traceability/index.mddiagrams
Adding a New DSC Resource¶
- Create
dsc/resources/<Name>/<Name>.psm1with class-based DSC resource - Create
dsc/resources/<Name>/<Name>.psd1module manifest - Add Pester 5 tests in
dsc/tests/<Name>.Tests.ps1usingInModuleScope - Run
pwsh -Command "Invoke-Pester dsc/tests/ -Output Detailed"— all tests must pass dsc/build.ps1will auto-generate the documentation page on next CI run- Add a nav entry in
mkdocs.ymlif the resource needs a dedicated page
Adding a New ADR¶
- Create
docs/adrs/<number>-<slug>.mdwith YAML front-matter including: id,title,status,date,related_requirements- Update
mkdocs.ymlnav — Architecture Decisions section - Update
docs/traceability/index.md— add the ADR to the matrix tables
Responding to Infrastructure Drift (ADR-0024)¶
The nightly drift-check job compares the deployed state (remote
backend) with the configuration using terraform plan
-detailed-exitcode. A drift failure means the world and the repository
have diverged:
- Open the failed workflow run — the human-readable drift report is in
the run summary and attached as the
drift-reportartefact (30-day retention); it is never committed to the repository - Classify each change: intended (someone changed infrastructure outside the pipeline) or unintended (unauthorised modification)
- Reconcile through the code, never by hand:
- intended change → port it into
terraform/and open a PR - unintended change → revert the infrastructure to the configuration-declared state
- Re-run the pipeline via a manual
workflow_dispatchand confirm thedrift-checkjob reports "No infrastructure drift" - If the job skipped with "No TERRAFORM_BACKEND_CONFIG secret", the remote state backend is not configured yet (see ADR-0024) — the check becomes active once the secret exists
Health Check Checklist¶
Run this checklist before any production deployment:
- [ ]
opa test example/policies/terraform/ -v— all policy tests pass - [ ]
pwsh -Command "Invoke-Pester example/dsc/tests/ -Output Detailed"— all DSC tests pass - [ ]
terraform -chdir=example/terraform validate— no validation errors - [ ]
mkdocs build --config-file example/mkdocs.yml --strict— no warnings or errors - [ ]
docker build -t dtds-example example/— image builds cleanly - [ ] GitHub Actions pipeline shows green on
mainbranch
Escalation Matrix¶
| Severity | Symptom | Owner | SLA |
|---|---|---|---|
| P1 | OPA gate blocking all PRs | DevOps Lead | 1 hour |
| P1 | GitHub Pages site unavailable | DevOps Lead | 1 hour |
| P2 | Policy false positive blocking valid PR | Security Engineer | 4 hours |
| P2 | Pester tests failing on main | DevOps Engineer | 4 hours |
| P3 | Documentation stale (>24h) | DevOps Engineer | 24 hours |
| P4 | Tool version outdated | Any engineer | Next sprint |