Removed ignore errors from db management in discourse

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-10 11:44:35 +02:00
parent 41d023abee
commit 707cc9d2d1
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
6 changed files with 25 additions and 16 deletions

View File

@ -1,4 +1,5 @@
hostname: "central-postgres"
network: "central_postgres"
port: 5432
docker:
images:

View File

@ -1,6 +1,6 @@
- name: Create Docker network for PostgreSQL
docker_network:
name: central_postgres
name: "{{ applications[application_id].network }}"
state: present
ipam_config:
- subnet: "{{ networks.local.postgres.subnet }}"
@ -15,7 +15,7 @@
POSTGRES_PASSWORD: "{{ applications[application_id].credentials.postgres_password }}"
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C" # Necessary for web-app-matrix
networks:
- name: central_postgres
- name: "{{ applications[application_id].network }}"
published_ports:
- "127.0.0.1:{{ applications[application_id].port }}:5432"
volumes:

View File

@ -133,7 +133,7 @@ def update_discourse(directory):
update_procedure("docker stop {{applications.discourse.container}}")
update_procedure("docker rm {{applications.discourse.container}}")
try:
update_procedure("docker network connect {{applications.discourse.network}} central-postgres")
update_procedure("docker network connect {{applications.discourse.network}} {{ applications.postgres.hostname }}")
except subprocess.CalledProcessError as e:
error_message = e.output.decode()
if "already exists" in error_message or "is already connected" in error_message:

View File

@ -43,20 +43,29 @@
meta: flush_handlers
when: run_once_docker_discourse is not defined
- name: "add {{applications[application_id].container}} to network central_postgres"
command:
cmd: "docker network connect central_postgres {{applications[application_id].container}}"
ignore_errors: true
- name: "Connect {{ applications[application_id].container }} to network {{ applications.postgres.network }}"
command: >
docker network connect {{ applications.postgres.network }} {{ applications[application_id].container }}
register: network_connect
failed_when: >
network_connect.rc != 0 and
'Error response from daemon: endpoint with name {{ applications[application_id].container }} already exists in network {{ applications.postgres.network }}'
not in network_connect.stderr
changed_when: network_connect.rc == 0
when:
- applications | is_feature_enabled('central_database',application_id)
- applications | is_feature_enabled('central_database', application_id)
- run_once_docker_discourse is not defined
- name: "remove central database from {{application_id}}_default"
command:
cmd: "docker network disconnect {{applications[application_id].network}} {{ database_host }}"
ignore_errors: true
- name: "Remove {{ applications[application_id].network }} from {{ database_host }}"
command: >
docker network disconnect {{ applications[application_id].network }} {{ database_host }}
register: network_disconnect
failed_when: >
network_disconnect.rc != 0 and
'is not connected to network {{ applications[application_id].network }}' not in network_disconnect.stderr
changed_when: network_disconnect.rc == 0
when:
- applications | is_feature_enabled('central_database',application_id)
- applications | is_feature_enabled('central_database', application_id)
- run_once_docker_discourse is not defined
- name: run the docker_discourse tasks once

View File

@ -9,7 +9,6 @@ features:
portfolio_iframe: true
central_database: true
oauth2: true
hostname: central-mariadb
csp:
flags:
style-src: