From e85324469454845acea46f2f86daa9551e3abfb4 Mon Sep 17 00:00:00 2001 From: turanisl Date: Wed, 11 Nov 2026 03:15:14 +0000 Subject: [PATCH] Chapter 6: Add release operations runbook (#10) --- secure-delivery/runbooks/RELEASE.md | 237 ++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 secure-delivery/runbooks/RELEASE.md diff --git a/secure-delivery/runbooks/RELEASE.md b/secure-delivery/runbooks/RELEASE.md new file mode 100644 index 0000000..c94952f --- /dev/null +++ b/secure-delivery/runbooks/RELEASE.md @@ -0,0 +1,237 @@ +# Chapter 6 — Release Operations Runbook + +## 1. Purpose + +Document the controlled release procedure for the Startup Pricing +Service using Jenkins, Docker, the Gitea OCI registry, Ansible, +and Docker Compose. + +This runbook covers the promotion of an approved application +release from staging to production-like deployment. + +All releases must preserve the existing Gitea, Jenkins, Caddy, +and Chapter 5 monitoring infrastructure. + +## 2. Roles and Responsibilities + +| Role | Responsibility | +|---|---| +| Developer | Prepare and review application changes | +| Jenkins | Execute tests, security gates, build, and delivery stages | +| Trusted Jenkins agent | Execute approved build and deployment operations | +| Release approver | Authorize production promotion | +| Deployment operator | Investigate failures and execute recovery procedures | + +For this assignment, Sergio will configure and execute the +delivery workflow. + +Actual production approval must be performed by an authorized +person through Jenkins and recorded in the release evidence. + +## 3. Preconditions + +Before starting a release: + +1. Confirm that the proposed changes have been reviewed. +2. Confirm that the release originates from protected `main`. +3. Confirm that the trusted Jenkins agent is available. +4. Confirm that Jenkins credentials are correctly restricted. +5. Confirm that Docker and Ansible are operational. +6. Confirm that the Gitea OCI registry is accessible. +7. Confirm that staging and production HTTPS endpoints are configured. +8. Confirm that the previous approved release is available for rollback. +9. Confirm that existing infrastructure is healthy. +10. Record the current application version and image digest. + +Do not begin a privileged deployment from an untrusted pull-request build. + +## 4. Source and Build Verification + +The Jenkins pipeline must: + +1. Check out the reviewed application source. +2. Record the full Git commit identifier. +3. Verify the Python interpreter version. +4. Run Python syntax checks. +5. Install the approved dependency set. +6. Execute the application unit tests. +7. Stop immediately if any required test fails. + +The build must use the approved Python base-image digest +and reproducible dependency versions. + +## 5. Security Gates + +Before release, execute: + +- Python dependency vulnerability scanning. +- Source-code secret scanning. +- Container image vulnerability scanning. + +Record the scanner versions, vulnerability database information, +timestamps, results, and exit codes. + +Any required scanner failure, unavailable vulnerability database, +or unapproved high/critical vulnerability must block release. + +Never bypass a failed security gate to continue deployment. + +## 6. Container Image Publication + +After successful tests and security checks: + +1. Build the application container image once. +2. Include the full application source commit in the image. +3. Tag the image using the approved registry naming convention. +4. Authenticate using protected Jenkins credentials. +5. Push the image to the Gitea OCI registry. +6. Retrieve its immutable repository digest. +7. Record the digest in the release traceability document. + +Do not use a mutable image tag as the deployment identity. + +## 7. Staging Deployment + +Use Ansible to deploy the approved immutable image to staging. + +Before deployment: + +1. Confirm the staging release record contains no placeholders. +2. Confirm the image digest matches the published image. +3. Confirm the deployment configuration commit is recorded. +4. Validate the Ansible playbook syntax. +5. Confirm the target is staging. + +Deploy using the approved staging release record. + +The deployment must not rebuild the application image. + +## 8. Staging Verification + +After deployment, verify: + +| Check | Expected Result | +|---|---| +| HTTPS certificate | Valid | +| `/health` | HTTP 200 and status `ok` | +| `/` | Correct version and source commit | +| `/price?quantity=3` for v1 | USD 30 | +| `/price?quantity=3` for v2 | USD 36 | +| Deployed image digest | Matches approved release digest | + +Capture the Ansible output and HTTPS verification evidence. + +If any check fails, stop the pipeline and follow the recovery runbook. + +## 9. Production Approval + +Production promotion requires a restricted Jenkins approval step. + +The approval must: + +1. Display the release version and immutable image digest. +2. Identify the staging verification result. +3. Require an authorized approver. +4. Enforce an approval timeout. +5. Record the actual approver and approval timestamp. + +A rejected or expired approval must block production deployment. + +Do not fabricate approval evidence. + +## 10. Production Deployment + +After approval: + +1. Select the approved production release record. +2. Verify that it uses the identical image digest as staging. +3. Record the deployment configuration commit. +4. Execute the production Ansible deployment. +5. Wait for application health verification. +6. Confirm the production HTTPS endpoint is reachable. + +The production deployment must not rebuild the image. + +## 11. Production Verification + +Verify the following: + +- HTTPS certificate validation succeeds. +- `/health` returns HTTP 200 and status `ok`. +- `/` returns the approved application version. +- `/` returns the expected application source commit. +- `/price?quantity=3` returns the expected total. +- The deployed repository digest matches the staging digest. +- Existing infrastructure remains operational. + +Record the production deployment timestamp and verification evidence. + +## 12. Release Traceability + +Update: + +`secure-delivery/releases/RELEASE_TRACEABILITY.md` + +Record: + +- Application version. +- Source commit. +- Deployment configuration commit. +- Jenkins build number and URL. +- Dependency and base-image versions. +- Security scan results. +- Published image digest. +- Staging verification. +- Production approver and approval time. +- Production verification. +- Evidence links. + +All values must be obtained from actual execution. + +## 13. Failed Release Handling + +If a required stage fails: + +1. Stop the release workflow. +2. Record the failed stage and timestamp. +3. Preserve relevant logs. +4. Confirm that production has not been unintentionally modified. +5. Determine whether staging recovery is necessary. +6. Follow the rollback and recovery runbook when applicable. +7. Correct the underlying problem in a reviewed commit. +8. Rerun the required tests and security gates. + +Do not silently retry an unsafe deployment or bypass failed checks. + +## 14. Post-Release Monitoring + +After a successful production deployment: + +1. Confirm the production HTTPS Blackbox probe is successful. +2. Confirm Prometheus receives the expected metrics. +3. Confirm the production application is visible in Grafana. +4. Record the deployment timestamp. +5. Compare monitoring observations with the release timeline. + +Preserve all existing Chapter 5 monitoring targets. + +## 15. Completion Criteria + +A release is complete only when: + +- Required tests pass. +- Required security gates pass. +- The image is published and its digest recorded. +- Staging deployment and verification succeed. +- Production approval is recorded. +- Production uses the identical approved image digest. +- Production verification succeeds. +- Monitoring remains operational. +- Release evidence is documented. + +## 16. Status + +Release operations runbook prepared. + +Actual execution, infrastructure configuration, approval, +and supporting evidence remain pending Sergio's implementation. \ No newline at end of file