feat: complete secure pricing delivery and rollback documentation
startup-product-gitea-ci/pipeline/pr-main There was a failure building this commit
startup-product-gitea-ci/pipeline/head There was a failure building this commit

This commit is contained in:
2026-11-13 21:07:53 -05:00
parent c6a53349ee
commit 36cec81744
52 changed files with 1716 additions and 5 deletions
+7
View File
@@ -0,0 +1,7 @@
.venv/
__pycache__/
*.pyc
.pytest_cache/
.git/
.env
.gitignore
+5
View File
@@ -0,0 +1,5 @@
.venv/
__pycache__/
*.pyc
.pytest_cache/
.env
+19
View File
@@ -0,0 +1,19 @@
FROM python:3.13-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
RUN useradd --create-home appuser
USER appuser
EXPOSE 5000
CMD ["python", "app.py"]
+20
View File
@@ -0,0 +1,20 @@
FROM python:3.13-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements-production.txt .
RUN pip install --no-cache-dir -r requirements-production.txt
RUN useradd --create-home appuser
COPY --chown=appuser:appuser app.py .
USER appuser
EXPOSE 5000
CMD ["gunicorn", "--workers", "2", "--bind", "0.0.0.0:5000", "app:app"]
@@ -0,0 +1,40 @@
---
- name: Check staging release before deployment
hosts: staging
gather_facts: false
vars:
container_name: startup-pricing-staging
release_image: startup-pricing:release-v2-20261113
tasks:
- name: Get desired release image ID
ansible.builtin.command:
argv:
- docker
- image
- inspect
- "{{ release_image }}"
- --format
- "{{ '{{.Id}}' }}"
register: desired_image
changed_when: false
- name: Get current container image ID
ansible.builtin.command:
argv:
- docker
- inspect
- "{{ container_name }}"
- --format
- "{{ '{{.Image}}' }}"
register: current_image
changed_when: false
failed_when: false
- name: Report whether image replacement is needed
ansible.builtin.debug:
msg: >-
Replacement needed:
{{ current_image.rc != 0 or
current_image.stdout != desired_image.stdout }}
+169
View File
@@ -0,0 +1,169 @@
---
- name: Deploy secure pricing service to staging
hosts: staging
gather_facts: false
vars:
container_name: startup-pricing-staging
release_image: startup-pricing:release-v2-20261113
expected_version: v2
tasks:
- name: Inspect current staging container
ansible.builtin.command:
argv:
- docker
- inspect
- "{{ container_name }}"
register: current_container
changed_when: false
failed_when: false
check_mode: false
- name: Confirm release image exists
ansible.builtin.command:
argv:
- docker
- image
- inspect
- "{{ release_image }}"
changed_when: false
check_mode: false
- name: Get desired release image ID
ansible.builtin.command:
argv:
- docker
- image
- inspect
- "{{ release_image }}"
- --format
- "{{ '{{.Id}}' }}"
register: desired_image
changed_when: false
check_mode: false
- name: Get current staging image ID
ansible.builtin.command:
argv:
- docker
- inspect
- "{{ container_name }}"
- --format
- "{{ '{{.Image}}' }}"
register: current_image
changed_when: false
failed_when: false
check_mode: false
- name: Determine whether staging replacement is required
ansible.builtin.set_fact:
replace_staging: >-
{{
current_image.rc != 0
or current_image.stdout != desired_image.stdout
or not (
(current_container.stdout | from_json | first).State.Running
if current_container.rc == 0
else false
)
}}
- name: Display replacement decision
ansible.builtin.debug:
msg: "Replacement needed: {{ replace_staging }}"
- name: Stop existing staging container if present
ansible.builtin.command:
argv:
- docker
- stop
- "{{ container_name }}"
when:
- not ansible_check_mode
- current_container.rc == 0
- replace_staging
- name: Remove existing staging container if present
ansible.builtin.command:
argv:
- docker
- rm
- "{{ container_name }}"
when:
- not ansible_check_mode
- current_container.rc == 0
- replace_staging
- name: Start secure staging container
ansible.builtin.command:
argv:
- docker
- run
- -d
- --name
- "{{ container_name }}"
- --memory=64m
- --memory-swap=128m
- --cpus=0.5
- --pids-limit=64
- --read-only
- --tmpfs
- /tmp:rw,nosuid,nodev,size=16m
- --security-opt
- no-new-privileges:true
- --cap-drop
- ALL
- -p
- 127.0.0.1:5062:5000
- "{{ release_image }}"
- gunicorn
- --workers
- "1"
- --bind
- 0.0.0.0:5000
- app:app
when:
- not ansible_check_mode
- replace_staging
- name: Wait for staging health endpoint
ansible.builtin.uri:
url: http://127.0.0.1:5062/health
method: GET
status_code: 200
return_content: true
register: staging_health
retries: 10
delay: 2
until: staging_health.status == 200
check_mode: false
when: not (ansible_check_mode and replace_staging)
- name: Verify staging health response
ansible.builtin.assert:
that:
- staging_health.json.status == "healthy"
success_msg: "Staging health check passed."
when: not (ansible_check_mode and replace_staging)
- name: Check staging pricing endpoint
ansible.builtin.uri:
url: http://127.0.0.1:5062/pricing
method: GET
status_code: 200
return_content: true
register: staging_pricing
retries: 10
delay: 2
until: staging_pricing.status == 200
check_mode: false
when: not (ansible_check_mode and replace_staging)
- name: Verify staging application version
ansible.builtin.assert:
that:
- staging_pricing.json.version == expected_version
success_msg: "Secure staging deployment succeeded."
when: not (ansible_check_mode and replace_staging)
+7
View File
@@ -0,0 +1,7 @@
[staging]
digitalocean ansible_host=143.244.173.110
[staging:vars]
ansible_user=root
ansible_ssh_private_key_file=~/.ssh/ssw590_digitalocean
ansible_python_interpreter=/usr/bin/python3
@@ -0,0 +1,33 @@
---
- name: Verify secure pricing staging deployment
hosts: staging
gather_facts: false
tasks:
- name: Inspect staging container
ansible.builtin.command:
argv:
- docker
- inspect
- startup-pricing-staging
register: staging_inspect
changed_when: false
- name: Check staging health endpoint
ansible.builtin.uri:
url: http://127.0.0.1:5062/health
method: GET
status_code: 200
return_content: true
register: staging_health
- name: Assert staging is healthy and running v2
ansible.builtin.assert:
that:
- staging_health.json.status == "healthy"
- staging_health.json.version == "v2"
success_msg: "Staging is healthy and running v2"
- name: Display verification result
ansible.builtin.debug:
msg: "Ansible verified the existing staging deployment successfully."
+25
View File
@@ -0,0 +1,25 @@
from flask import Flask, jsonify
app = Flask(__name__)
@app.get("/health")
def health():
return jsonify({"status": "healthy"}), 200
@app.get("/pricing")
def pricing():
return jsonify({
"service": "Startup Pricing Service",
"version": "v1",
"plans": [
{"name": "Basic", "price": 10},
{"name": "Pro", "price": 25},
{"name": "Enterprise", "price": 50}
]
}), 200
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)
@@ -0,0 +1,2 @@
Image=startup-pricing:release-v1-20261113 ID=sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027 Platform=linux/amd64 User=appuser
Image=startup-pricing:release-v2-20261113 ID=sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707 Platform=linux/amd64 User=appuser
@@ -0,0 +1,4 @@
digitalocean | SUCCESS => {
"changed": false,
"ping": "pong"
}
@@ -0,0 +1,22 @@
PLAY [Verify secure pricing staging deployment] ********************************
TASK [Inspect staging container] ***********************************************
ok: [digitalocean]
TASK [Check staging health endpoint] *******************************************
ok: [digitalocean]
TASK [Assert staging is healthy and running v2] ********************************
ok: [digitalocean] => {
"changed": false,
"msg": "Staging is healthy and running v2"
}
TASK [Display verification result] *********************************************
ok: [digitalocean] => {
"msg": "Ansible verified the existing staging deployment successfully."
}
PLAY RECAP *********************************************************************
digitalocean : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@@ -0,0 +1,50 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
skipping: [digitalocean]
TASK [Confirm release image exists] ********************************************
skipping: [digitalocean]
TASK [Get desired release image ID] ********************************************
skipping: [digitalocean]
TASK [Get current staging image ID] ********************************************
skipping: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
[ERROR]: Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'replace_staging': The filter plugin 'ansible.builtin.from_json' failed: Expecting value: line 1 column 1 (char 0)
Task failed.
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:54:7
52 failed_when: false
53
54 - name: Determine whether staging replacement is required
^ column 7
<<< caused by >>>
Finalization of task args for 'ansible.builtin.set_fact' failed.
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:55:7
53
54 - name: Determine whether staging replacement is required
55 ansible.builtin.set_fact:
^ column 7
<<< caused by >>>
Error while resolving value for 'replace_staging': The filter plugin 'ansible.builtin.from_json' failed: Expecting value: line 1 column 1 (char 0)
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:56:26
54 - name: Determine whether staging replacement is required
55 ansible.builtin.set_fact:
56 replace_staging: >-
^ column 26
fatal: [digitalocean]: FAILED! => {"changed": false, "msg": "Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'replace_staging': The filter plugin 'ansible.builtin.from_json' failed: Expecting value: line 1 column 1 (char 0)"}
PLAY RECAP *********************************************************************
digitalocean : ok=0 changed=0 unreachable=0 failed=1 skipped=4 rescued=0 ignored=0
@@ -0,0 +1,38 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
skipping: [digitalocean]
TASK [Confirm release image exists] ********************************************
skipping: [digitalocean]
TASK [Get desired release image ID] ********************************************
skipping: [digitalocean]
TASK [Get current staging image ID] ********************************************
skipping: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
ok: [digitalocean]
TASK [Stop existing staging container if present] ******************************
skipping: [digitalocean]
TASK [Remove existing staging container if present] ****************************
skipping: [digitalocean]
TASK [Start secure staging container] ******************************************
skipping: [digitalocean]
TASK [Wait for staging health endpoint] ****************************************
ok: [digitalocean]
TASK [Verify staging version] **************************************************
ok: [digitalocean] => {
"changed": false,
"msg": "Secure staging deployment succeeded."
}
PLAY RECAP *********************************************************************
digitalocean : ok=3 changed=0 unreachable=0 failed=0 skipped=7 rescued=0 ignored=0
@@ -0,0 +1,55 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
skipping: [digitalocean]
TASK [Confirm release image exists] ********************************************
skipping: [digitalocean]
TASK [Get desired release image ID] ********************************************
skipping: [digitalocean]
TASK [Get current staging image ID] ********************************************
skipping: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
ok: [digitalocean]
TASK [Stop existing staging container if present] ******************************
skipping: [digitalocean]
TASK [Remove existing staging container if present] ****************************
skipping: [digitalocean]
TASK [Start secure staging container] ******************************************
skipping: [digitalocean]
TASK [Wait for staging health endpoint] ****************************************
skipping: [digitalocean]
TASK [Verify staging version] **************************************************
[ERROR]: Task failed: Error while evaluating conditional: object of type 'dict' has no attribute 'json'
Task failed.
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:118:7
116 until: staging_health.status == 200
117
118 - name: Verify staging version
^ column 7
<<< caused by >>>
Error while evaluating conditional: object of type 'dict' has no attribute 'json'
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:121:13
119 ansible.builtin.assert:
120 that:
121 - staging_health.json.status == "healthy"
^ column 13
fatal: [digitalocean]: FAILED! => {"changed": false, "msg": "Task failed: Error while evaluating conditional: object of type 'dict' has no attribute 'json'"}
PLAY RECAP *********************************************************************
digitalocean : ok=1 changed=0 unreachable=0 failed=1 skipped=8 rescued=0 ignored=0
@@ -0,0 +1,38 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
ok: [digitalocean]
TASK [Confirm release image exists] ********************************************
ok: [digitalocean]
TASK [Get desired release image ID] ********************************************
ok: [digitalocean]
TASK [Get current staging image ID] ********************************************
ok: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
ok: [digitalocean]
TASK [Stop existing staging container if present] ******************************
changed: [digitalocean]
TASK [Remove existing staging container if present] ****************************
changed: [digitalocean]
TASK [Start secure staging container] ******************************************
changed: [digitalocean]
TASK [Wait for staging health endpoint] ****************************************
ok: [digitalocean]
TASK [Verify staging version] **************************************************
ok: [digitalocean] => {
"changed": false,
"msg": "Secure staging deployment succeeded."
}
PLAY RECAP *********************************************************************
digitalocean : ok=10 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@@ -0,0 +1,50 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
ok: [digitalocean]
TASK [Confirm release image exists] ********************************************
ok: [digitalocean]
TASK [Get desired release image ID] ********************************************
ok: [digitalocean]
TASK [Get current staging image ID] ********************************************
ok: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
[ERROR]: Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'replace_staging': object of type 'list' has no attribute 'State'
Task failed.
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:59:7
57 check_mode: false
58
59 - name: Determine whether staging replacement is required
^ column 7
<<< caused by >>>
Finalization of task args for 'ansible.builtin.set_fact' failed.
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:60:7
58
59 - name: Determine whether staging replacement is required
60 ansible.builtin.set_fact:
^ column 7
<<< caused by >>>
Error while resolving value for 'replace_staging': object of type 'list' has no attribute 'State'
Origin: /Users/nageshwaranmanikumar/Desktop/SSW590/startup-product/pricing-service/ansible/deploy-staging.yml:61:26
59 - name: Determine whether staging replacement is required
60 ansible.builtin.set_fact:
61 replace_staging: >-
^ column 26
fatal: [digitalocean]: FAILED! => {"changed": false, "msg": "Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'replace_staging': object of type 'list' has no attribute 'State'"}
PLAY RECAP *********************************************************************
digitalocean : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
@@ -0,0 +1,43 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
ok: [digitalocean]
TASK [Confirm release image exists] ********************************************
ok: [digitalocean]
TASK [Get desired release image ID] ********************************************
ok: [digitalocean]
TASK [Get current staging image ID] ********************************************
ok: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
ok: [digitalocean]
TASK [Display replacement decision] ********************************************
ok: [digitalocean] => {
"msg": "Replacement needed: False"
}
TASK [Stop existing staging container if present] ******************************
skipping: [digitalocean]
TASK [Remove existing staging container if present] ****************************
skipping: [digitalocean]
TASK [Start secure staging container] ******************************************
skipping: [digitalocean]
TASK [Wait for staging health endpoint] ****************************************
ok: [digitalocean]
TASK [Verify staging version] **************************************************
ok: [digitalocean] => {
"changed": false,
"msg": "Secure staging deployment succeeded."
}
PLAY RECAP *********************************************************************
digitalocean : ok=8 changed=0 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
@@ -0,0 +1,43 @@
PLAY [Deploy secure pricing service to staging] ********************************
TASK [Inspect current staging container] ***************************************
ok: [digitalocean]
TASK [Confirm release image exists] ********************************************
ok: [digitalocean]
TASK [Get desired release image ID] ********************************************
ok: [digitalocean]
TASK [Get current staging image ID] ********************************************
ok: [digitalocean]
TASK [Determine whether staging replacement is required] ***********************
ok: [digitalocean]
TASK [Display replacement decision] ********************************************
ok: [digitalocean] => {
"msg": "Replacement needed: False"
}
TASK [Stop existing staging container if present] ******************************
skipping: [digitalocean]
TASK [Remove existing staging container if present] ****************************
skipping: [digitalocean]
TASK [Start secure staging container] ******************************************
skipping: [digitalocean]
TASK [Wait for staging health endpoint] ****************************************
ok: [digitalocean]
TASK [Verify staging version] **************************************************
ok: [digitalocean] => {
"changed": false,
"msg": "Secure staging deployment succeeded."
}
PLAY RECAP *********************************************************************
digitalocean : ok=8 changed=0 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
@@ -0,0 +1,2 @@
playbook: ansible/deploy-staging.yml
@@ -0,0 +1,2 @@
playbook: ansible/deploy-staging.yml
@@ -0,0 +1,2 @@
playbook: ansible/verify-staging.yml
@@ -0,0 +1,11 @@
total used free shared buff/cache available
Mem: 458Mi 334Mi 7.7Mi 3.0Mi 140Mi 124Mi
Swap: 1.0Gi 756Mi 267Mi
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
50fb5110c6d3 grafana 10.67% 25.88MiB / 192MiB 13.48% 113MB / 447MB 2.96TB / 714GB 31
2d22225910a8 prometheus 8.27% 20.63MiB / 128MiB 16.12% 632MB / 122MB 1.32TB / 444GB 8
d480acd19bde blackbox-exporter 1.89% 9.273MiB / 32MiB 28.98% 1.17GB / 241MB 425GB / 109GB 8
7b33270bc99a node-exporter 0.00% 652KiB / 32MiB 1.99% 31.1MB / 463MB 463GB / 139GB 4
58e75ecb35c7 caddy 1.60% 13.61MiB / 458.2MiB 2.97% 3.66GB / 4.05GB 819GB / 171GB 8
9f243097358c jenkins 0.48% 139.3MiB / 384MiB 36.29% 69.7MB / 163MB 330GB / 88.1GB 46
e45237a53503 gitea 13.53% 31.66MiB / 458.2MiB 6.91% 125MB / 2.79GB 3.8TB / 1.71TB 51
@@ -0,0 +1,16 @@
PLAY [Check staging release before deployment] *********************************
TASK [Get desired release image ID] ********************************************
ok: [digitalocean]
TASK [Get current container image ID] ******************************************
ok: [digitalocean]
TASK [Report whether image replacement is needed] ******************************
ok: [digitalocean] => {
"msg": "Replacement needed: False"
}
PLAY RECAP *********************************************************************
digitalocean : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@@ -0,0 +1,2 @@
playbook: ansible/check-staging-release.yml
@@ -0,0 +1,231 @@
[
{
"Id": "d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e",
"Created": "2026-11-14T00:10:40.598265925Z",
"Path": "gunicorn",
"Args": [
"--workers",
"1",
"--bind",
"0.0.0.0:5000",
"app:app"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 286251,
"ExitCode": 0,
"Error": "",
"StartedAt": "2026-11-14T00:10:41.260368681Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707",
"ResolvConfPath": "/var/lib/docker/containers/d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e/hostname",
"HostsPath": "/var/lib/docker/containers/d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e/hosts",
"LogPath": "/var/lib/docker/containers/d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e/d6fee4b0ca309694dc1a40e4e143d243e5fd465c5c59b20fbe6c7b0df2f2a03e-json.log",
"Name": "/startup-pricing-staging",
"RestartCount": 0,
"Driver": "overlayfs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"5000/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "5062"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"ConsoleSize": [
0,
0
],
"CapAdd": null,
"CapDrop": [
"ALL"
],
"CgroupnsMode": "private",
"Dns": null,
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": true,
"SecurityOpt": [
"no-new-privileges:true"
],
"Tmpfs": {
"/tmp": "rw,nosuid,nodev,size=16m"
},
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"Isolation": "",
"CpuShares": 0,
"Memory": 67108864,
"NanoCpus": 500000000,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": [],
"BlkioDeviceWriteBps": [],
"BlkioDeviceReadIOps": [],
"BlkioDeviceWriteIOps": [],
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"MemoryReservation": 0,
"MemorySwap": 134217728,
"MemorySwappiness": null,
"OomKillDisable": null,
"PidsLimit": 64,
"Ulimits": [],
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/acpi",
"/proc/asound",
"/proc/interrupts",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/sched_debug",
"/proc/scsi",
"/proc/timer_list",
"/proc/timer_stats",
"/sys/devices/virtual/powercap",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"Storage": {
"RootFS": {
"Snapshot": {
"Name": "overlayfs"
}
}
},
"Mounts": [],
"Config": {
"Hostname": "d6fee4b0ca30",
"Domainname": "",
"User": "appuser",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5000/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"GPG_KEY=7169605F62C751356D054A26A821E680E5FA6305",
"PYTHON_VERSION=3.13.18",
"PYTHON_SHA256=abb0102e6d4ae027509bcb82327d9dd85515b44a3ba8ad538cfc5e9847029f68",
"PYTHONDONTWRITEBYTECODE=1",
"PYTHONUNBUFFERED=1"
],
"Cmd": [
"gunicorn",
"--workers",
"1",
"--bind",
"0.0.0.0:5000",
"app:app"
],
"Image": "startup-pricing:release-v2-20261113",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": null,
"Labels": {}
},
"NetworkSettings": {
"SandboxID": "f9bb6a75eb59bb42120d9d7ad2c6b43da4e0253b2704f37b8b300f4a3accc3b8",
"SandboxKey": "/var/run/docker/netns/f9bb6a75eb59",
"Ports": {
"5000/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "5062"
}
]
},
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"DriverOpts": null,
"GwPriority": 0,
"NetworkID": "dcc4503fc49e15773f240848c06ef6380ae3e4fbcfd4c8bdd316c6199cfcab63",
"EndpointID": "66c439997e5e4e43ae2883761373c6a81838ab77be13221127c2a34ef5a494d2",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"MacAddress": "c2:40:1e:46:99:2d",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": null
}
}
},
"ImageManifestDescriptor": {
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:e8c9b28b2cb30e27f138d95bdd14ade4ea56202156b9761ae57ecfbef51a36ef",
"size": 1999,
"platform": {
"architecture": "amd64",
"os": "linux"
}
}
}
]
@@ -0,0 +1 @@
ImageID=sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707 Status=running RestartCount=0
@@ -0,0 +1,7 @@
Chapter 6 - Ansible Staging Idempotency Verification
Verified after real Ansible deployment
ContainerID=49b27eaa9b37d8929165de042bbcfee85953e1038ea8b0f8df6c2d7cdd590377 Status=running RestartCount=0 ImageID=sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707
Health endpoint:
{"status":"healthy","version":"v2"}
@@ -0,0 +1 @@
Image=startup-pricing:release-v2-20261113 Memory=67108864 MemorySwap=134217728 NanoCPUs=500000000 PidsLimit=64 ReadOnly=true CapDrop=["ALL"] Security=["no-new-privileges:true"] Restart=no Ports={"5000/tcp":[{"HostIp":"127.0.0.1","HostPort":"5062"}]} Tmpfs={"/tmp":"rw,nosuid,nodev,size=16m"} Cmd=["gunicorn","--workers","1","--bind","0.0.0.0:5000","app:app"]
@@ -0,0 +1,41 @@
=== STAGING HEALTH ===
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1HTTP/1.1 200 OK
Server: gunicorn
Date: Sat, 14 Nov 2026 00:11:31 GMT
Connection: close
Content-Type: application/json
Content-Length: 36
{"status":"healthy","version":"v2"}
00 36 100 36 0 0 5268 0 --:--:-- --:--:-- --:--:-- 6000
=== STAGING PRICING ===
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1HTTP/1.1 200 OK
Server: gunicorn
Date: Sat, 14 Nov 2026 00:11:31 GMT
Connection: close
Content-Type: application/json
Content-Length: 179
{"plans":[{"name":"Starter","price":5},{"name":"Basic","price":12},{"name":"Pro","price":30},{"name":"Enterprise","price":60}],"service":"Startup Pricing Service","version":"v2"}
00 179 100 179 0 0 53673 0 --:--:-- --:--:-- --:--:-- 59666
=== CONTAINER STATUS ===
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6fee4b0ca30 startup-pricing:release-v2-20261113 "gunicorn --workers …" 52 seconds ago Up 50 seconds 127.0.0.1:5062->5000/tcp startup-pricing-staging
=== RESOURCE USAGE ===
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
d6fee4b0ca30 startup-pricing-staging 0.05% 8.047MiB / 64MiB 12.57% 3.07kB / 2.66kB 54.1MB / 48.3MB 2
=== STARTUP LOGS ===
[2026-11-14 00:10:44 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2026-11-14 00:10:44 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2026-11-14 00:10:44 +0000] [1] [INFO] Using worker: sync
[2026-11-14 00:10:44 +0000] [8] [INFO] Booting worker with pid: 8
@@ -0,0 +1,11 @@
Chapter 6 - Final v2 Recovery Verification
Date: Fri Nov 13 20:56:52 EST 2026
=== Container ===
Status=running Image=startup-pricing:release-v2-20261113 RestartCount=0 ImageID=sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707
=== Health ===
{"status":"healthy","version":"v2"}
=== Pricing ===
{"plans":[{"name":"Starter","price":5},{"name":"Basic","price":12},{"name":"Pro","price":30},{"name":"Enterprise","price":60}],"service":"Startup Pricing Service","version":"v2"}
+2
View File
@@ -0,0 +1,2 @@
d9f8a6e420728b45c5ad56e80e0b7189d79cb9e09b9eddebec8aea2501c2d536 releases/startup-pricing-v1-20261113.tar
b7bfe31fbfdfd0d706503a3119d14cc6c21d3d377fb58588004ed571ddfae2ae releases/startup-pricing-v2-20261113.tar
@@ -0,0 +1,2 @@
Flask>=3.1,<4.0
gunicorn>=23,<24
+1
View File
@@ -0,0 +1 @@
Flask>=3.1,<4.0
+33
View File
@@ -0,0 +1,33 @@
import unittest
from app import app
class PricingServiceTests(unittest.TestCase):
def setUp(self):
self.client = app.test_client()
def test_health_endpoint(self):
response = self.client.get("/health")
self.assertEqual(response.status_code, 200)
self.assertEqual(
response.get_json()["status"],
"healthy"
)
def test_pricing_endpoint(self):
response = self.client.get("/pricing")
self.assertEqual(response.status_code, 200)
data = response.get_json()
self.assertEqual(data["version"], "v1")
self.assertEqual(len(data["plans"]), 3)
self.assertEqual(data["plans"][0]["name"], "Basic")
self.assertEqual(data["plans"][0]["price"], 10)
if __name__ == "__main__":
unittest.main()
+25
View File
@@ -0,0 +1,25 @@
from flask import Flask, jsonify
app = Flask(__name__)
@app.get("/health")
def health():
return jsonify({"status": "healthy"}), 200
@app.get("/pricing")
def pricing():
return jsonify({
"service": "Startup Pricing Service",
"version": "v1",
"plans": [
{"name": "Basic", "price": 10},
{"name": "Pro", "price": 25},
{"name": "Enterprise", "price": 50}
]
}), 200
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)
@@ -0,0 +1,7 @@
.venv/
__pycache__/
*.pyc
.pytest_cache/
.git/
.env
.gitignore
+19
View File
@@ -0,0 +1,19 @@
FROM python:3.13-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
RUN useradd --create-home appuser
USER appuser
EXPOSE 5000
CMD ["python", "app.py"]
@@ -0,0 +1,20 @@
FROM python:3.13-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements-production.txt .
RUN pip install --no-cache-dir -r requirements-production.txt
RUN useradd --create-home appuser
COPY --chown=appuser:appuser app.py .
USER appuser
EXPOSE 5000
CMD ["gunicorn", "--workers", "2", "--bind", "0.0.0.0:5000", "app:app"]
+26
View File
@@ -0,0 +1,26 @@
from flask import Flask, jsonify
app = Flask(__name__)
@app.get("/health")
def health():
return jsonify({"status": "healthy", "version": "v2"}), 200
@app.get("/pricing")
def pricing():
return jsonify({
"service": "Startup Pricing Service",
"version": "v2",
"plans": [
{"name": "Starter", "price": 5},
{"name": "Basic", "price": 12},
{"name": "Pro", "price": 30},
{"name": "Enterprise", "price": 60}
]
}), 200
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)
@@ -0,0 +1,2 @@
Flask>=3.1,<4.0
gunicorn>=23,<24
@@ -0,0 +1 @@
Flask>=3.1,<4.0
+32
View File
@@ -0,0 +1,32 @@
import unittest
from app import app
class PricingServiceV2Tests(unittest.TestCase):
def setUp(self):
self.client = app.test_client()
def test_health_endpoint(self):
response = self.client.get("/health")
self.assertEqual(response.status_code, 200)
data = response.get_json()
self.assertEqual(data["status"], "healthy")
self.assertEqual(data["version"], "v2")
def test_pricing_endpoint(self):
response = self.client.get("/pricing")
self.assertEqual(response.status_code, 200)
data = response.get_json()
self.assertEqual(data["version"], "v2")
self.assertEqual(len(data["plans"]), 4)
self.assertEqual(data["plans"][0]["name"], "Starter")
self.assertEqual(data["plans"][0]["price"], 5)
if __name__ == "__main__":
unittest.main()