mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-07-19 15:04:23 +02:00
Moved database port mapping to central port configuration file
This commit is contained in:
parent
6fbe550afe
commit
fb0ca533ae
@ -1,6 +1,9 @@
|
|||||||
ports:
|
ports:
|
||||||
# Ports which are exposed to localhost
|
# Ports which are exposed to localhost
|
||||||
localhost:
|
localhost:
|
||||||
|
database:
|
||||||
|
svc-db-postgres: 5432
|
||||||
|
svc-db-mariadb: 3306
|
||||||
# https://developer.mozilla.org/de/docs/Web/API/WebSockets_API
|
# https://developer.mozilla.org/de/docs/Web/API/WebSockets_API
|
||||||
websocket:
|
websocket:
|
||||||
mastodon: 4001
|
mastodon: 4001
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
database_instance: "{{ applications[ 'svc-db-' ~ database_type ].hostname if applications | get_app_conf(database_application_id, 'features.central_database', False) else database_application_id }}"
|
database_id: "svc-db-{{ database_type }}"
|
||||||
database_host: "{{ applications[ 'svc-db-' ~ database_type ].hostname if applications | get_app_conf(database_application_id, 'features.central_database', False) else 'database' }}"
|
database_instance: "{{ applications[ database_id ].hostname if applications | get_app_conf(database_application_id, 'features.central_database', False) else database_application_id }}"
|
||||||
|
database_host: "{{ applications[ database_id ].hostname if applications | get_app_conf(database_application_id, 'features.central_database', False) else 'database' }}"
|
||||||
database_name: "{{ applications | get_app_conf(database_application_id, 'database.name', False) | default( database_application_id ) }}" # The overwritte configuration is needed by bigbluebutton
|
database_name: "{{ applications | get_app_conf(database_application_id, 'database.name', False) | default( database_application_id ) }}" # The overwritte configuration is needed by bigbluebutton
|
||||||
database_username: "{{ applications | get_app_conf(database_application_id, 'database.username', False) | default( database_application_id )}}" # The overwritte configuration is needed by bigbluebutton
|
database_username: "{{ applications | get_app_conf(database_application_id, 'database.username', False) | default( database_application_id )}}" # The overwritte configuration is needed by bigbluebutton
|
||||||
database_password: "{{ applications | get_app_conf(database_application_id, 'credentials.database_password', true) }}"
|
database_password: "{{ applications | get_app_conf(database_application_id, 'credentials.database_password', true) }}"
|
||||||
database_port: "{{ applications[ 'svc-db-' ~ database_type ].port }}"
|
database_port: "{{ ports.localhost.database[ database_id ] }}"
|
||||||
database_env: "{{docker_compose.directories.env}}{{database_type}}.env"
|
database_env: "{{docker_compose.directories.env}}{{database_type}}.env"
|
||||||
database_url_jdbc: "jdbc:{{ database_type if database_type == 'mariadb' else 'postgresql' }}://{{ database_host }}:{{ database_port }}/{{ database_name }}"
|
database_url_jdbc: "jdbc:{{ database_type if database_type == 'mariadb' else 'postgresql' }}://{{ database_host }}:{{ database_port }}/{{ database_name }}"
|
||||||
database_url_full: "{{database_type}}://{{database_username}}:{{database_password}}@{{database_host}}:{{database_port}}/{{ database_name }}"
|
database_url_full: "{{database_type}}://{{database_username}}:{{database_password}}@{{database_host}}:{{database_port}}/{{ database_name }}"
|
@ -1,5 +1,4 @@
|
|||||||
version: "latest"
|
version: "latest"
|
||||||
hostname: "svc-db-mariadb"
|
hostname: "svc-db-mariadb"
|
||||||
network: "<< defaults_applications[svc-db-mariadb].hostname >>"
|
network: "<< defaults_applications[svc-db-mariadb].hostname >>"
|
||||||
port: 3306
|
|
||||||
volume: "<< defaults_applications[svc-db-mariadb].hostname >>_data"
|
volume: "<< defaults_applications[svc-db-mariadb].hostname >>_data"
|
@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
- name: install MariaDB
|
- name: install MariaDB
|
||||||
docker_container:
|
docker_container:
|
||||||
name: "{{ applications['svc-db-mariadb'].hostname }}"
|
name: "{{ mariadb_hostname }}"
|
||||||
image: "mariadb:{{applications['svc-db-mariadb'].version}}"
|
image: "mariadb:{{applications['svc-db-mariadb'].version}}"
|
||||||
detach: yes
|
detach: yes
|
||||||
env:
|
env:
|
||||||
MARIADB_ROOT_PASSWORD: "{{applications['svc-db-mariadb'].credentials.root_password}}"
|
MARIADB_ROOT_PASSWORD: "{{mariadb_root_pwd}}"
|
||||||
MARIADB_AUTO_UPGRADE: "1"
|
MARIADB_AUTO_UPGRADE: "1"
|
||||||
networks:
|
networks:
|
||||||
- name: "{{ applications['svc-db-mariadb'].network }}"
|
- name: "{{ applications['svc-db-mariadb'].network }}"
|
||||||
@ -23,7 +23,7 @@
|
|||||||
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud
|
command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud
|
||||||
restart_policy: "{{docker_restart_policy}}"
|
restart_policy: "{{docker_restart_policy}}"
|
||||||
healthcheck:
|
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
|
interval: 3s
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
retries: 5
|
retries: 5
|
||||||
@ -36,9 +36,9 @@
|
|||||||
state: present
|
state: present
|
||||||
when: run_once_docker_mariadb is not defined
|
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:
|
community.docker.docker_container_info:
|
||||||
name: "{{ applications['svc-db-mariadb'].hostname }}"
|
name: "{{ mariadb_hostname }}"
|
||||||
register: db_info
|
register: db_info
|
||||||
until:
|
until:
|
||||||
- db_info.containers is defined
|
- db_info.containers is defined
|
||||||
@ -56,7 +56,7 @@
|
|||||||
name: "{{ database_name }}"
|
name: "{{ database_name }}"
|
||||||
state: present
|
state: present
|
||||||
login_user: root
|
login_user: root
|
||||||
login_password: "{{ applications['svc-db-mariadb'].credentials.root_password }}"
|
login_password: "{{ mariadb_root_pwd }}"
|
||||||
login_host: 127.0.0.1
|
login_host: 127.0.0.1
|
||||||
login_port: "{{ database_port }}"
|
login_port: "{{ database_port }}"
|
||||||
encoding: "{{ database_encoding }}"
|
encoding: "{{ database_encoding }}"
|
||||||
@ -70,7 +70,7 @@
|
|||||||
priv: '{{database_name}}.*:ALL'
|
priv: '{{database_name}}.*:ALL'
|
||||||
state: present
|
state: present
|
||||||
login_user: root
|
login_user: root
|
||||||
login_password: "{{applications['svc-db-mariadb'].credentials.root_password}}"
|
login_password: "{{mariadb_root_pwd}}"
|
||||||
login_host: 127.0.0.1
|
login_host: 127.0.0.1
|
||||||
login_port: "{{database_port}}"
|
login_port: "{{database_port}}"
|
||||||
|
|
||||||
@ -78,7 +78,7 @@
|
|||||||
# @todo Remove if this works fine in the future.
|
# @todo Remove if this works fine in the future.
|
||||||
#- name: Grant database privileges
|
#- name: Grant database privileges
|
||||||
# ansible.builtin.shell:
|
# 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:
|
# args:
|
||||||
# executable: /bin/bash
|
# executable: /bin/bash
|
||||||
|
|
||||||
|
@ -1 +1,3 @@
|
|||||||
application_id: svc-db-mariadb
|
application_id: svc-db-mariadb
|
||||||
|
mariadb_hostname: "{{ applications | get_app_conf(application_id, 'hostname', True) }}"
|
||||||
|
mariadb_root_pwd: "{{ applications['svc-db-mariadb'].credentials.root_password }}"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
hostname: "svc-db-postgres"
|
hostname: "svc-db-postgres"
|
||||||
network: "<< defaults_applications[svc-db-postgres].hostname >>"
|
network: "<< defaults_applications[svc-db-postgres].hostname >>"
|
||||||
port: 5432
|
|
||||||
volume: "<< defaults_applications[svc-db-postgres].hostname >>"
|
volume: "<< defaults_applications[svc-db-postgres].hostname >>"
|
||||||
docker:
|
docker:
|
||||||
services:
|
services:
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
networks:
|
networks:
|
||||||
- name: "{{ applications | get_app_conf(application_id, 'network', True) }}"
|
- name: "{{ applications | get_app_conf(application_id, 'network', True) }}"
|
||||||
published_ports:
|
published_ports:
|
||||||
- "127.0.0.1:{{ applications | get_app_conf(application_id, 'port', True) }}:5432"
|
- "127.0.0.1:{{ database_port }}:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ applications['svc-db-postgres'].volume }}:/var/lib/postgresql/data"
|
- "{{ applications['svc-db-postgres'].volume }}:/var/lib/postgresql/data"
|
||||||
restart_policy: "{{ docker_restart_policy }}"
|
restart_policy: "{{ docker_restart_policy }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user