Moved database port mapping to central port configuration file

This commit is contained in:
2025-07-13 23:06:11 +02:00
parent 6fbe550afe
commit fb0ca533ae
7 changed files with 19 additions and 15 deletions

View File

@@ -8,11 +8,11 @@
- name: install MariaDB
docker_container:
name: "{{ applications['svc-db-mariadb'].hostname }}"
name: "{{ mariadb_hostname }}"
image: "mariadb:{{applications['svc-db-mariadb'].version}}"
detach: yes
env:
MARIADB_ROOT_PASSWORD: "{{applications['svc-db-mariadb'].credentials.root_password}}"
MARIADB_ROOT_PASSWORD: "{{mariadb_root_pwd}}"
MARIADB_AUTO_UPGRADE: "1"
networks:
- name: "{{ applications['svc-db-mariadb'].network }}"
@@ -23,7 +23,7 @@
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud
restart_policy: "{{docker_restart_policy}}"
healthcheck:
test: "/usr/bin/mariadb --user=root --password={{applications['svc-db-mariadb'].credentials.root_password}} --execute \"SHOW DATABASES;\""
test: "/usr/bin/mariadb --user=root --password={{mariadb_root_pwd}} --execute \"SHOW DATABASES;\""
interval: 3s
timeout: 1s
retries: 5
@@ -36,9 +36,9 @@
state: present
when: run_once_docker_mariadb is not defined
- name: "Wait until the MariaDB container (hostname {{ applications['svc-db-mariadb'].hostname }}) is healthy"
- name: "Wait until the MariaDB container with hostname '{{ mariadb_hostname }}' is healthy"
community.docker.docker_container_info:
name: "{{ applications['svc-db-mariadb'].hostname }}"
name: "{{ mariadb_hostname }}"
register: db_info
until:
- db_info.containers is defined
@@ -56,7 +56,7 @@
name: "{{ database_name }}"
state: present
login_user: root
login_password: "{{ applications['svc-db-mariadb'].credentials.root_password }}"
login_password: "{{ mariadb_root_pwd }}"
login_host: 127.0.0.1
login_port: "{{ database_port }}"
encoding: "{{ database_encoding }}"
@@ -70,7 +70,7 @@
priv: '{{database_name}}.*:ALL'
state: present
login_user: root
login_password: "{{applications['svc-db-mariadb'].credentials.root_password}}"
login_password: "{{mariadb_root_pwd}}"
login_host: 127.0.0.1
login_port: "{{database_port}}"
@@ -78,7 +78,7 @@
# @todo Remove if this works fine in the future.
#- name: Grant database privileges
# ansible.builtin.shell:
# cmd: "docker exec {{applications['svc-db-mariadb'].hostname }} mariadb -u root -p{{ applications['svc-db-mariadb'].credentials.root_password }} -e \"GRANT ALL PRIVILEGES ON `{{database_name}}`.* TO '{{database_username}}'@'%';\""
# cmd: "docker exec {{mariadb_hostname }} mariadb -u root -p{{ mariadb_root_pwd }} -e \"GRANT ALL PRIVILEGES ON `{{database_name}}`.* TO '{{database_username}}'@'%';\""
# args:
# executable: /bin/bash