Document verified production rollback and staging configuration recovery
startup-product-gitea-ci/pipeline/pr-main This commit looks good
startup-product-gitea-ci/pipeline/pr-main This commit looks good
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
---
|
||||
- name: Chapter 6 staging configuration recovery
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
serial: 1
|
||||
any_errors_fatal: true
|
||||
|
||||
vars:
|
||||
staging_dir: /opt/secure-delivery/chapter6-staging
|
||||
staging_mode: healthy
|
||||
|
||||
tasks:
|
||||
- name: Validate authorized operation
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- staging_mode in ['healthy', 'failure']
|
||||
- staging_authorized | default(false) | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Verify production before staging operation
|
||||
ansible.builtin.uri:
|
||||
url: https://pricing.nageshwaran.dev/health
|
||||
return_content: true
|
||||
register: production_before
|
||||
|
||||
- name: Confirm production is healthy
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- production_before.json.status == 'healthy'
|
||||
- production_before.json.version == 'v2'
|
||||
|
||||
- name: Install healthy configuration
|
||||
ansible.builtin.copy:
|
||||
src: ../recovery/staging/compose.yml
|
||||
dest: "{{ staging_dir }}/compose.yml"
|
||||
mode: '0600'
|
||||
backup: true
|
||||
|
||||
- name: Install failure override
|
||||
ansible.builtin.copy:
|
||||
src: ../recovery/staging/compose.failure.yml
|
||||
dest: "{{ staging_dir }}/compose.failure.yml"
|
||||
mode: '0600'
|
||||
backup: true
|
||||
|
||||
- name: Apply selected staging configuration
|
||||
ansible.builtin.command:
|
||||
argv: "{{ compose_args }}"
|
||||
vars:
|
||||
compose_args: >-
|
||||
{{
|
||||
['flock', '-n', '/run/lock/chapter6-production.lock',
|
||||
'docker', 'compose', '-p', 'chapter6-staging',
|
||||
'-f', staging_dir + '/compose.yml']
|
||||
+ (['-f', staging_dir + '/compose.failure.yml']
|
||||
if staging_mode == 'failure' else [])
|
||||
+ ['up', '-d', '--wait', '--wait-timeout', '45',
|
||||
'--no-build', '--pull', 'never']
|
||||
}}
|
||||
register: deployment
|
||||
failed_when: false
|
||||
|
||||
- name: Record Compose deployment result
|
||||
ansible.builtin.debug:
|
||||
var: deployment
|
||||
|
||||
- name: Verify production after staging operation
|
||||
ansible.builtin.uri:
|
||||
url: https://pricing.nageshwaran.dev/health
|
||||
return_content: true
|
||||
register: production_after
|
||||
|
||||
- name: Confirm production remains healthy
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- production_after.json.status == 'healthy'
|
||||
- production_after.json.version == 'v2'
|
||||
|
||||
- name: Enforce deployment gate
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- deployment.rc == 0
|
||||
fail_msg: "Compose deployment failed; delivery blocked"
|
||||
|
||||
- name: Verify restored staging HTTPS
|
||||
ansible.builtin.uri:
|
||||
url: https://staging-pricing.nageshwaran.dev/health
|
||||
return_content: true
|
||||
register: staging_health
|
||||
retries: 5
|
||||
delay: 2
|
||||
until: staging_health.status == 200
|
||||
when: staging_mode == 'healthy'
|
||||
|
||||
- name: Verify restored staging version
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- staging_health.json.status == 'healthy'
|
||||
- staging_health.json.version == 'v2'
|
||||
when: staging_mode == 'healthy'
|
||||
Reference in New Issue
Block a user