diff --git a/secure-delivery/runbooks/CLEANUP.md b/secure-delivery/runbooks/CLEANUP.md new file mode 100644 index 0000000..302d881 --- /dev/null +++ b/secure-delivery/runbooks/CLEANUP.md @@ -0,0 +1,166 @@ +Chapter 6 — Safe Cleanup Runbook + +1. Purpose + +Document the safe removal of Chapter 6 application resources after the assignment has been graded and cleanup has been authorized. + +Cleanup must preserve all existing infrastructure established in Chapters 3, 4, and 5. + +Do not execute these procedures before grading or without team authorization. + +2. Infrastructure That Must Be Preserved + +The following resources must remain operational: + +* Gitea and its repositories. +* Jenkins and its existing pipelines. +* Caddy and its existing HTTPS routes. +* Prometheus and its existing monitoring configuration. +* Grafana, dashboards, and persistent data. +* Node Exporter. +* Blackbox Exporter. +* Existing Docker volumes and networks. +* Previous assignment evidence and documentation. + +Chapter 6 cleanup must never involve stopping the Docker daemon or deleting shared infrastructure. + +3. Resources Eligible for Cleanup + +Only resources created specifically for Chapter 6 may be removed: + +Resource Cleanup Condition +pricing-staging Compose project After grading and authorization +pricing-production Compose project After grading and authorization +/opt/startup/pricing-staging After deployment records are preserved +/opt/startup/pricing-production After deployment records are preserved +Chapter 6-specific Caddy routes After application containers are removed +Chapter 6-specific monitoring targets After monitoring evidence is preserved +Chapter 6-specific Jenkins credentials After confirming they are not shared +Chapter 6-specific registry images Only when retention is no longer required + +Do not assume a resource is exclusive to Chapter 6 without verifying ownership. + +4. Preconditions + +Before cleanup: + +1. Confirm that Chapter 6 grading is complete. +2. Obtain authorization from the team. +3. Preserve the final IT manual PDF. +4. Preserve Jenkins build logs and security scan reports. +5. Preserve release traceability records. +6. Preserve approval evidence. +7. Preserve staging and production verification screenshots. +8. Preserve rollback and failed-deployment evidence. +9. Record the current Docker containers, networks, and volumes. +10. Confirm which resources belong exclusively to Chapter 6. + +5. Application Container Cleanup + +Identify the actual Chapter 6 Compose project names and deployment directories. + +Expected project names: + +* pricing-staging +* pricing-production + +Verify the running containers before proceeding. + +Stop and remove only the containers associated with the selected Chapter 6 application projects. + +Do not remove shared networks or volumes. + +Never use: + +docker compose down -v +docker system prune -a +docker volume prune + +Do not use broad cleanup commands that could affect unrelated services. + +6. Deployment Directory Cleanup + +After confirming that the application containers have been removed and evidence has been preserved, remove only the verified Chapter 6 deployment directories. + +Expected directories: + +/opt/startup/pricing-staging +/opt/startup/pricing-production + +Verify the exact paths before deletion. + +Never recursively delete the parent /opt/startup directory. + +7. Reverse Proxy Cleanup + +Remove only the Chapter 6 staging and production application routes from the existing Caddy configuration. + +Preserve all existing Gitea, Jenkins, Grafana, and monitoring routes. + +Validate the updated Caddy configuration before applying it. + +After applying the change, verify that existing HTTPS services remain reachable. + +8. Monitoring Cleanup + +Remove only the Chapter 6 production application probe from the existing monitoring configuration. + +Preserve all previously configured monitoring targets. + +Validate the Prometheus configuration before applying changes. + +Confirm that existing dashboards and monitoring targets remain operational. + +9. Registry and Credentials + +Before removing any registry images or Jenkins credentials: + +1. Confirm that they belong exclusively to Chapter 6. +2. Confirm that they are not referenced by another deployment. +3. Preserve required release records. +4. Confirm that image retention is no longer necessary. +5. Obtain authorization for deletion. + +Never delete shared registry credentials or Jenkins credentials used by earlier chapters. + +10. Post-Cleanup Verification + +After cleanup, confirm: + +Component Expected Result +Gitea Operational +Jenkins Operational +Caddy Existing HTTPS routes operational +Prometheus Operational +Grafana Existing dashboards available +Node Exporter Metrics available +Blackbox Exporter Existing probes operational +Chapter 6 staging application Removed +Chapter 6 production application Removed +Shared Docker volumes Preserved +Shared Docker networks Preserved + +Record the verification results and cleanup timestamp. + +11. Evidence Requirements + +Preserve: + +* Cleanup authorization. +* Date and time of cleanup. +* Operator identity. +* List of removed resources. +* Relevant commands and outputs. +* Before-and-after container inventory. +* Verification that existing services remain operational. +* Any unexpected issues and their resolution. + +Do not claim cleanup was successful without actual verification. + +12. Status + +This cleanup runbook has been prepared for future use. + +No Chapter 6 resources have been removed as part of preparing this document. + +Actual cleanup must occur only after grading and explicit authorization. \ No newline at end of file