Refactor DB initialization handling: externalize database_init flag for svc-db-mariadb and svc-db-postgres, remove internal auto-detection, and pass explicit init signal from sys-stk-back-stateful. Improves clarity, avoids incorrect credential lookups, and stabilizes central DB setup.

Reference: ChatGPT conversation https://chatgpt.com/share/692def1c-a79c-800f-b7dd-35e1845424bf
This commit is contained in:
2025-12-01 20:40:30 +01:00
parent 116c20d61d
commit 8314d7e6a6
8 changed files with 19 additions and 17 deletions

View File

@@ -1 +1,2 @@
postgres_gis_enabled: false # Needed by mobilizon
postgres_gis_enabled: false # Needed by mobilizon
database_init: false # When true a database is initialized

View File

@@ -11,4 +11,4 @@
- name: "Initialize database for '{{ database_name }}'"
include_tasks: 02_init.yml
when: POSTGRES_INIT | bool
when: database_init | bool

View File

@@ -18,7 +18,6 @@ POSTGRES_NETWORK_NAME: "{{ applications | get_app_conf(applic
POSTGRES_SUBNET: "{{ networks.local['svc-db-postgres'].subnet }}"
POSTGRES_PASSWORD: "{{ applications | get_app_conf(application_id, 'credentials.POSTGRES_PASSWORD') }}"
POSTGRES_PORT: "{{ database_port | default(ports.localhost.database[ application_id ]) }}"
POSTGRES_INIT: "{{ database_username is defined and database_password is defined and database_name is defined }}"
POSTGRES_EXPOSE_LOCAL: True # Exposes the db to localhost, almost everytime neccessary
POSTGRES_CUSTOM_IMAGE_NAME: "postgres_custom"
POSTGRES_LOCAL_HOST: "127.0.0.1"