Files
computer-playbook/roles/sys-svc-rdbms/tasks/main.yml
kevinveenbirkenbachandClaude Opus 5 06f5905d64 fix(sys-svc-rdbms): patch the persisted password before the health gate again
1f870b1e5 gave the patch one call site and put it in post_deploy.yml, which runs
after the deploy has waited for the stack. 3831c8f804 had named the constraint in
its own subject line: before the health gate. An app whose health check
authenticates against its own database fails that check with the password it
persisted, compose gives up with "dependency failed to start: container matomo is
unhealthy", and nothing behind the gate ever runs -- including the patch that
would have fixed it.

Measured, not argued: with the call in post_deploy.yml a local compose deploy of
five roles passed its first pass at ok=4571 failed=0 and died in the second, the
one that carries the rotated credential. With the call back in front, all three
passes report failed=0 and the Playwright specs pass in both.

sys-svc-rdbms/tasks/main.yml is where it goes: the stack include reaches it
before anything comes up, it is per-consumer rather than per-role-once, and it
still resolves the declaration through the same path, so there is still exactly
one call site. The patch reads the volume from the host and needs no running
container, which is what makes the earlier position possible at all; before the
first deploy has created the volume it exits without doing anything.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 11:04:04 +02:00

79 lines
3.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
# nocheck: run-once
- name: "📝 For '{{ application_id }}': Freeze database consumer id before includes"
set_fact:
_database_consumer_id: "{{ database_consumer_id | default(application_id) }}"
changed_when: false
- name: "🔍 For '{{ application_id }}/{{ _database_consumer_id }}': Resolve shared mode"
set_fact:
_sys_svc_rdbms_consumer_local: "{{ lookup('database', _database_consumer_id, 'local') | bool }}"
_sys_svc_rdbms_central_db_enabled: >-
{{ not (lookup('database', _database_consumer_id, 'local') | bool)
and (groups[lookup('database', _database_consumer_id, 'id')] | default([])) | length > 0 }}
changed_when: false
- name: "🔍 For '{{ application_id }}': Find the compose file rendering the engine"
ansible.builtin.stat:
path: "{{ lookup('path_absolute', 'roles', application_id, 'templates/compose.yml.j2') }}"
register: _sys_svc_rdbms_compose_template
delegate_to: localhost
changed_when: false
- name: "🔧 For '{{ application_id }}/{{ _database_consumer_id }}': Apply dedicated setup"
include_tasks: dedicated.yml
when:
- _sys_svc_rdbms_consumer_local | bool
- _sys_svc_rdbms_compose_template.stat.exists
- name: "🔑 Realign '{{ application_id }}' persisted password before the health gate"
ansible.builtin.include_tasks: "{{ _app_persisted_credentials }}"
vars:
_app_persisted_credentials: "{{ lookup('path_absolute', 'roles/' ~ application_id ~ '/tasks/utils/patch/db_credentials.yml') }}"
when: _app_persisted_credentials is exists
- name: 🗄️ Central Database Logic
block:
- name: "✅ For '{{ application_id }}': Assert shared database provider was preloaded"
ansible.builtin.assert:
that:
- >-
lookup(
'vars',
'run_once_' ~ (_database_provider_role | replace('-', '_')),
default='__missing__'
) != '__missing__'
fail_msg: >-
Shared database provider '{{ _database_provider_role }}' was not preloaded by
sys-service-loader before sys-svc-rdbms ran.
when: MODE_ASSERT_LOCAL | bool
- name: "🎬 For '{{ application_id }}': Init dedicated db on preloaded provider"
ansible.builtin.include_role:
name: "{{ _database_provider_role }}"
vars:
application_id: "{{ _database_provider_role }}"
database_init: true
compose_repository_pull: false
compose_mode_force: ""
database_consumer_id: "{{ _database_consumer_id }}"
- name: "➕ For '{{ application_id }}': Add Entry for Backup Procedure"
include_tasks: utils/seed_backup.yml
when:
- "'svc-bkp-volume-2-local' in group_names"
- IS_STACK_HOST | bool
vars:
_database_provider_role: "{{ lookup('database', _database_consumer_id, 'id') }}"
database_consumer_id: "{{ _database_consumer_id }}"
database_type: "{{ _database_type }}"
database_instance: "{{ lookup('database', _database_consumer_id, 'instance') }}"
database_host: "{{ lookup('database', _database_consumer_id, 'host') }}"
database_port: "{{ lookup('database', _database_consumer_id, 'port') }}"
database_name: "{{ lookup('database', _database_consumer_id, 'name') }}"
database_username: "{{ lookup('database', _database_consumer_id, 'username') }}"
database_password: "{{ lookup('database', _database_consumer_id, 'password') }}"
when:
- _sys_svc_rdbms_central_db_enabled | bool
- inventory_hostname in (groups[lookup('database', _database_consumer_id, 'id')] | default([]))