docs: restore SRE chapter and integrate secure delivery chapter 6 #13
@@ -0,0 +1,83 @@
|
||||
---
|
||||
- name: Prepare protected staging Compose configuration
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
serial: 1
|
||||
|
||||
vars:
|
||||
staging_directory: /opt/secure-delivery/chapter6-staging
|
||||
staging_container: startup-pricing-staging
|
||||
expected_original_id: "8686354a1be5c1d181bcfbf64c610caf286e4a82b475021394f13a7abb4db49b"
|
||||
|
||||
tasks:
|
||||
- name: Inspect original staging container
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- inspect
|
||||
- "{{ staging_container }}"
|
||||
register: staging_inspect
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Verify original staging identity
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (staging_inspect.stdout | from_json)[0].Id == expected_original_id
|
||||
- (staging_inspect.stdout | from_json)[0].State.Running
|
||||
|
||||
- name: Create protected staging directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ staging_directory }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: Install healthy Compose configuration
|
||||
ansible.builtin.copy:
|
||||
src: ../recovery/staging/compose.yml
|
||||
dest: "{{ staging_directory }}/compose.yml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
backup: true
|
||||
|
||||
- name: Validate Compose configuration
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- -p
|
||||
- chapter6-staging
|
||||
- -f
|
||||
- "{{ staging_directory }}/compose.yml"
|
||||
- config
|
||||
- --quiet
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Verify existing staging health
|
||||
ansible.builtin.uri:
|
||||
url: http://127.0.0.1:5062/health
|
||||
return_content: true
|
||||
status_code: 200
|
||||
register: staging_health
|
||||
check_mode: false
|
||||
|
||||
- name: Verify production HTTPS health
|
||||
ansible.builtin.uri:
|
||||
url: https://pricing.nageshwaran.dev/health
|
||||
return_content: true
|
||||
status_code: 200
|
||||
register: production_health
|
||||
check_mode: false
|
||||
|
||||
- name: Confirm both environments remain healthy
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- staging_health.json.status == "healthy"
|
||||
- staging_health.json.version == "v2"
|
||||
- production_health.json.status == "healthy"
|
||||
- production_health.json.version == "v2"
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"services": {
|
||||
"pricing": {
|
||||
"command": [
|
||||
"gunicorn",
|
||||
"--workers",
|
||||
"1",
|
||||
"--bind",
|
||||
"0.0.0.0:8001",
|
||||
"app:app"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "chapter6-staging",
|
||||
"networks": {
|
||||
"jenkins_internal": {
|
||||
"name": "jenkins_jenkins_internal",
|
||||
"ipam": {},
|
||||
"external": true
|
||||
},
|
||||
"proxy_internal": {
|
||||
"external": true,
|
||||
"name": "gitea_gitea_internal"
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"pricing": {
|
||||
"cap_drop": [
|
||||
"ALL"
|
||||
],
|
||||
"cpus": 0.5,
|
||||
"command": [
|
||||
"gunicorn",
|
||||
"--workers",
|
||||
"1",
|
||||
"--bind",
|
||||
"0.0.0.0:5000",
|
||||
"app:app"
|
||||
],
|
||||
"container_name": "startup-pricing-staging",
|
||||
"entrypoint": null,
|
||||
"healthcheck": {
|
||||
"test": [
|
||||
"CMD",
|
||||
"python",
|
||||
"-c",
|
||||
"import urllib.request,json; r=urllib.request.urlopen('http://127.0.0.1:5000/health',timeout=2); assert r.status == 200 and json.load(r)['status'] == 'healthy'"
|
||||
],
|
||||
"timeout": "3s",
|
||||
"interval": "3s",
|
||||
"retries": 3,
|
||||
"start_period": "5s"
|
||||
},
|
||||
"image": "git.nageshwaran.dev/ssw590-startup/startup-pricing@sha256:14d520f6fbe60c9cc5e661551a03e944de3a2ad777a64c316ec397ee765db22d",
|
||||
"mem_limit": "67108864",
|
||||
"memswap_limit": "134217728",
|
||||
"networks": {
|
||||
"jenkins_internal": null,
|
||||
"proxy_internal": null
|
||||
},
|
||||
"pids_limit": 64,
|
||||
"ports": [
|
||||
{
|
||||
"mode": "ingress",
|
||||
"host_ip": "127.0.0.1",
|
||||
"target": 5000,
|
||||
"published": "5062",
|
||||
"protocol": "tcp"
|
||||
}
|
||||
],
|
||||
"pull_policy": "never",
|
||||
"read_only": true,
|
||||
"restart": "no",
|
||||
"security_opt": [
|
||||
"no-new-privileges:true"
|
||||
],
|
||||
"tmpfs": [
|
||||
"/tmp:rw,nosuid,nodev,size=16m"
|
||||
],
|
||||
"user": "appuser"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user