Add the locked pricing service, trusted-agent pipeline, Ansible deployments, security gates, recovery runbooks, prerequisite evidence, and preparation manual. Prepared with Codex assistance. Vincent explicitly authorized this local commit and will handle the push. Assessed releases and recovery exercises remain pending.
75 lines
2.9 KiB
YAML
75 lines
2.9 KiB
YAML
- name: Deploy a selected immutable pricing release
|
|
hosts: delivery
|
|
become: true
|
|
vars:
|
|
project_dir: "/opt/startup/pricing-{{ target_env }}"
|
|
tasks:
|
|
- name: Validate release selection
|
|
ansible.builtin.assert:
|
|
that:
|
|
- target_env in ['staging', 'production']
|
|
- "'@sha256:' in release_image"
|
|
- expected_version in ['v1', 'v2']
|
|
- expected_total | int > 0
|
|
- public_url.startswith('https://')
|
|
- proxy_network | length > 0
|
|
- expected_commit is match('^[0-9a-f]{40}$')
|
|
- configuration_commit is match('^[0-9a-f]{40}$')
|
|
- release_image is match('^git[.]yebilly[.]me/ssw590-group1/pricing@sha256:[0-9a-f]{64}$')
|
|
- proxy_network == 'gitea_web'
|
|
- public_url == ('https://staging.yebilly.me' if target_env == 'staging' else 'https://app.yebilly.me')
|
|
- expected_total | int == (30 if expected_version == 'v1' else 36)
|
|
- name: Create deployment directory
|
|
ansible.builtin.file:
|
|
path: "{{ project_dir }}"
|
|
state: directory
|
|
mode: '0750'
|
|
- name: Render selected Compose configuration
|
|
ansible.builtin.template:
|
|
src: compose.yaml.j2
|
|
dest: "{{ project_dir }}/compose.yaml"
|
|
mode: '0640'
|
|
- name: Converge application without rebuilding
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ project_dir }}"
|
|
project_name: "pricing-{{ target_env }}"
|
|
state: present
|
|
build: never
|
|
pull: missing
|
|
wait: true
|
|
wait_timeout: 90
|
|
- name: Verify health through public TLS endpoint
|
|
ansible.builtin.uri:
|
|
url: "{{ public_url }}/health"
|
|
return_content: true
|
|
validate_certs: true
|
|
register: health
|
|
until: health.status == 200 and health.json.status == 'ok'
|
|
retries: 12
|
|
delay: 5
|
|
changed_when: false
|
|
- name: Read release identity
|
|
ansible.builtin.uri:
|
|
url: "{{ public_url }}/"
|
|
return_content: true
|
|
register: identity
|
|
changed_when: false
|
|
- name: Exercise business behavior
|
|
ansible.builtin.uri:
|
|
url: "{{ public_url }}/price?quantity=3"
|
|
return_content: true
|
|
register: price
|
|
changed_when: false
|
|
- name: Check release identity and calculation
|
|
ansible.builtin.assert:
|
|
that:
|
|
- identity.json.version == expected_version
|
|
- health.json.version == expected_version
|
|
- identity.json.commit == expected_commit
|
|
- price.json.total | int == expected_total | int
|
|
- name: Preserve the selected non-secret release metadata
|
|
ansible.builtin.copy:
|
|
dest: "{{ project_dir }}/release.json"
|
|
mode: '0640'
|
|
content: "{{ {'release_image': release_image, 'source_commit': expected_commit, 'configuration_commit': configuration_commit, 'version': expected_version, 'expected_total': expected_total, 'public_url': public_url} | to_nice_json }}\n"
|