Replaced enable_central_database by configuration in application

This commit is contained in:
Kevin Veen-Birkenbach 2025-02-21 05:06:39 +01:00
parent b6eb866b36
commit 9f41e25166
22 changed files with 84 additions and 43 deletions

View File

@ -18,14 +18,20 @@ defaults_applications:
company_name: "{{primary_domain}}" company_name: "{{primary_domain}}"
company_email: "{{administrator_email}}" company_email: "{{administrator_email}}"
setup_admin_email: "{{administrator_email}}" setup_admin_email: "{{administrator_email}}"
database:
central_storage: True
## Attendize ## Attendize
attendize: attendize:
version: "latest" version: "latest"
database:
central_storage: True
## Baserow ## Baserow
baserow: baserow:
version: "latest" version: "latest"
database:
central_storage: True
## Big Blue Button ## Big Blue Button
bigbluebutton: bigbluebutton:
@ -33,6 +39,8 @@ defaults_applications:
setup: false # Set to true in inventory file for initial setup setup: false # Set to true in inventory file for initial setup
oidc: oidc:
enabled: true # Activate OIDC enabled: true # Activate OIDC
database:
central_storage: True
## Bluesky ## Bluesky
bluesky: bluesky:
@ -42,6 +50,8 @@ defaults_applications:
#jwt_secret: # Needs to be defined in inventory file - Use: openssl rand -base64 64 | tr -d '\n' #jwt_secret: # Needs to be defined in inventory file - Use: openssl rand -base64 64 | tr -d '\n'
#plc_rotation_key_k256_private_key_hex: # Needs to be defined in inventory file - Use: openssl rand -hex 32 #plc_rotation_key_k256_private_key_hex: # Needs to be defined in inventory file - Use: openssl rand -hex 32
#admin_password: # Needs to be defined in inventory file - Use: openssl rand -base64 16 #admin_password: # Needs to be defined in inventory file - Use: openssl rand -base64 16
database:
central_storage: True
## Discourse: ## Discourse:
discourse: discourse:
@ -51,25 +61,35 @@ defaults_applications:
# database_password: # Needs to be defined in inventory file # database_password: # Needs to be defined in inventory file
oidc: oidc:
enabled: true # Activate OIDC enabled: true # Activate OIDC
database:
central_storage: True
## Friendica ## Friendica
friendica: friendica:
version: "latest" version: "latest"
oidc: oidc:
enabled: true # Activate OIDC. Plugin is not working yet enabled: true # Activate OIDC. Plugin is not working yet
database:
central_storage: True
## Funkwhale ## Funkwhale
funkwhale: funkwhale:
version: "1.4.0" version: "1.4.0"
ldap_enabled: True # Enables LDAP by default ldap_enabled: True # Enables LDAP by default
database:
central_storage: True
## Gitea ## Gitea
gitea: gitea:
version: "latest" version: "latest"
database:
central_storage: True
## Gitlab ## Gitlab
gitlab: gitlab:
version: "latest" version: "latest"
database:
central_storage: True
## Joomla ## Joomla
joomla: joomla:
@ -80,6 +100,8 @@ defaults_applications:
version: "latest" version: "latest"
administrator_username: "{{administrator_username}}" # Administrator Username for Keycloak administrator_username: "{{administrator_username}}" # Administrator Username for Keycloak
ldap_enabled: True # Enables LDAP by default ldap_enabled: True # Enables LDAP by default
database:
central_storage: True
# database_password: # Needs to be defined in inventory file # database_password: # Needs to be defined in inventory file
# administrator_password: # Needs to be defined in inventory file # administrator_password: # Needs to be defined in inventory file
@ -113,6 +135,8 @@ defaults_applications:
public_api_activated: False # Security hole. Can be used for spaming public_api_activated: False # Security hole. Can be used for spaming
version: "latest" # Docker Image version version: "latest" # Docker Image version
setup: false # Set true in inventory file to execute the setup and initializing procedures setup: false # Set true in inventory file to execute the setup and initializing procedures
database:
central_storage: True
mailu: mailu:
version: "2024.06" # Docker Image Version version: "2024.06" # Docker Image Version
@ -121,7 +145,8 @@ defaults_applications:
enabled: true # Activate OIDC for Mailu enabled: true # Activate OIDC for Mailu
domain: "{{primary_domain}}" # The main domain from which mails will be send \ email suffix behind @ domain: "{{primary_domain}}" # The main domain from which mails will be send \ email suffix behind @
# I don't know why the database deactivation is necessary # I don't know why the database deactivation is necessary
enable_central_database: False # Deactivate central database for mailu database:
central_storage: False # Deactivate central database for mailu
credentials: credentials:
# secret_key: # Set to a randomly generated 16 bytes string # secret_key: # Set to a randomly generated 16 bytes string
# database_password: # Needs to be set in inventory file # database_password: # Needs to be set in inventory file
@ -140,12 +165,16 @@ defaults_applications:
# auth_token: Null # Needs to be set in inventory file # auth_token: Null # Needs to be set in inventory file
css: css:
enabled: false # The css isn't optimized yet for Matomo enabled: false # The css isn't optimized yet for Matomo
database:
central_storage: True
## Mastodon ## Mastodon
mastodon: mastodon:
version: "latest" version: "latest"
single_user_mode: false # Set true for initial setup single_user_mode: false # Set true for initial setup
setup: false # Set true in inventory file to execute the setup and initializing procedures setup: false # Set true in inventory file to execute the setup and initializing procedures
database:
central_storage: True
oidc: oidc:
enabled: true # Activate OIDC for Mastodon enabled: true # Activate OIDC for Mastodon
credentials: credentials:
@ -172,6 +201,8 @@ defaults_applications:
element: element:
version: "latest" version: "latest"
setup: false # Set true in inventory file to execute the setup and initializing procedures setup: false # Set true in inventory file to execute the setup and initializing procedures
database:
central_storage: True
## Moodle ## Moodle
moodle: moodle:
@ -179,10 +210,14 @@ defaults_applications:
administrator_name: "{{administrator_username}}" administrator_name: "{{administrator_username}}"
administrator_email: "{{administrator_email}}" administrator_email: "{{administrator_email}}"
version: "latest" version: "latest"
database:
central_storage: True
## MyBB ## MyBB
mybb: mybb:
version: "latest" version: "latest"
database:
central_storage: True
## Nextcloud ## Nextcloud
nextcloud: nextcloud:
@ -192,6 +227,8 @@ defaults_applications:
oidc: oidc:
enabled: true # Activate OIDC for Nextcloud enabled: true # Activate OIDC for Nextcloud
force_import: False # Forces the import of the LDIF files force_import: False # Forces the import of the LDIF files
database:
central_storage: True
## OAuth2 Proxy ## OAuth2 Proxy
oauth2_proxy: oauth2_proxy:
@ -209,6 +246,8 @@ defaults_applications:
application: "proxy" application: "proxy"
port: "80" port: "80"
ldap_enabled: True # Enables LDAP by default ldap_enabled: True # Enables LDAP by default
database:
central_storage: True
## Peertube ## Peertube
peertube: peertube:
@ -222,11 +261,15 @@ defaults_applications:
enabled: true enabled: true
port: "80" port: "80"
application: "application" application: "application"
database:
central_storage: True
## Pixelfed ## Pixelfed
pixelfed: pixelfed:
titel: "Pictures on {{primary_domain}}" titel: "Pictures on {{primary_domain}}"
version: "latest" version: "latest"
database:
central_storage: True
## Postgres ## Postgres
# Please set an version in your inventory file - Rolling release for postgres isn't recommended # Please set an version in your inventory file - Rolling release for postgres isn't recommended
@ -236,10 +279,14 @@ defaults_applications:
# Snipe-IT # Snipe-IT
snipe_it: snipe_it:
version: "latest" version: "latest"
database:
central_storage: True
## Taiga ## Taiga
taiga: taiga:
version: "latest" version: "latest"
database:
central_storage: True
## YOURLS ## YOURLS
yourls: yourls:
@ -250,7 +297,8 @@ defaults_applications:
application: "application" application: "application"
port: "80" port: "80"
location: "/admin/" # Protects the admin area location: "/admin/" # Protects the admin area
database:
central_storage: True
wordpress: wordpress:
# Deactivate Global theming for wordpress role # Deactivate Global theming for wordpress role
@ -261,3 +309,5 @@ defaults_applications:
# for wordpress based on the theming values and import it. # for wordpress based on the theming values and import it.
css: css:
enabled: false enabled: false
database:
central_storage: True

View File

@ -1,6 +1,3 @@
## Enable Central Postgress and MariaDB instead of dedicated container per application
enable_central_database: true
## Enable Storage Optimizer for Docker Volumes ## Enable Storage Optimizer for Docker Volumes
enable_system_storage_optimizer: true enable_system_storage_optimizer: true

View File

@ -47,7 +47,7 @@ When executed, the role will:
1. Load database configuration variables. 1. Load database configuration variables.
2. Generate the appropriate environment file for the database. 2. Generate the appropriate environment file for the database.
3. Incorporate the Docker Compose routines. 3. Incorporate the Docker Compose routines.
4. Create a central database if `enable_central_database` is set to `true`. 4. Create a central database if `applications[application_id].database.central_storage` is set to `true`.
--- ---

View File

@ -14,9 +14,9 @@
src: "env/{{database_type}}.env.j2" src: "env/{{database_type}}.env.j2"
dest: "{{database_env}}" dest: "{{database_env}}"
notify: docker compose project build and setup notify: docker compose project build and setup
when: not enable_central_database | bool when: not applications[application_id].database.central_storage | bool
- name: create central database - name: create central database
include_role: include_role:
name: "docker-{{database_type}}" name: "docker-{{database_type}}"
when: enable_central_database | bool when: applications[application_id].database.central_storage | bool

View File

@ -1,5 +1,5 @@
# This template needs to be included in docker-compose.yml, which depend on a mariadb database # This template needs to be included in docker-compose.yml, which depend on a mariadb database
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
database: database:
container_name: {{application_id}}-database container_name: {{application_id}}-database
logging: logging:

View File

@ -1,5 +1,5 @@
# This template needs to be included in docker-compose.yml, which depend on a postgres database # This template needs to be included in docker-compose.yml, which depend on a postgres database
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
database: database:
image: postgres:{{applications.postgres.database_version}}-alpine image: postgres:{{applications.postgres.database_version}}-alpine
container_name: {{application_id}}-database container_name: {{application_id}}-database

View File

@ -1,5 +1,5 @@
database_instance: "{{ 'central-' + database_type if enable_central_database | bool else application_id }}" database_instance: "{{ 'central-' + database_type if applications[application_id].database.central_storage | bool else application_id }}"
database_host: "{{ 'central-' + database_type if enable_central_database | bool else 'database' }}" database_host: "{{ 'central-' + database_type if applications[application_id].database.central_storage | bool else 'database' }}"
database_name: "{{ application_id }}" database_name: "{{ application_id }}"
database_username: "{{ application_id }}" database_username: "{{ application_id }}"
database_port: "{{ 3306 if database_type == 'mariadb' else 5432 }}" database_port: "{{ 3306 if database_type == 'mariadb' else 5432 }}"

View File

@ -11,7 +11,7 @@
command: command:
cmd: "docker network connect {{applications.discourse.network}} central-{{ database_type }}" cmd: "docker network connect {{applications.discourse.network}} central-{{ database_type }}"
ignore_errors: true ignore_errors: true
when: enable_central_database | bool when: applications[application_id].database.central_storage | bool
listen: recreate discourse listen: recreate discourse
- name: rebuild discourse - name: rebuild discourse

View File

@ -65,10 +65,10 @@
command: command:
cmd: "docker network connect central_postgres {{applications.discourse.container}}" cmd: "docker network connect central_postgres {{applications.discourse.container}}"
ignore_errors: true ignore_errors: true
when: enable_central_database | bool when: applications[application_id].database.central_storage | bool
- name: "remove central database from {{application_id}}_default" - name: "remove central database from {{application_id}}_default"
command: command:
cmd: "docker network disconnect {{applications.discourse.network}} central-{{ database_type }}" cmd: "docker network disconnect {{applications.discourse.network}} central-{{ database_type }}"
ignore_errors: true ignore_errors: true
when: enable_central_database | bool when: applications[application_id].database.central_storage | bool

View File

@ -1,5 +1,5 @@
templates: templates:
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
- "templates/postgres.template.yml" - "templates/postgres.template.yml"
{% endif %} {% endif %}
#- "templates/redis.template.yml" #- "templates/redis.template.yml"

View File

@ -4,11 +4,6 @@ database_type: "mariadb"
cert_mount_directory: "{{docker_compose.directories.volumes}}certs/" cert_mount_directory: "{{docker_compose.directories.volumes}}certs/"
enable_wildcard_certificate: false enable_wildcard_certificate: false
# I don't know why this configuration is necessary.
# Propabldy due to a database migration problem, or dificulties to configure an external db in mailu
# @todo research
enable_central_database: "{{applications.mailu.enable_central_database}}"
# Use dedicated source for oidc if activated # Use dedicated source for oidc if activated
# @see https://github.com/heviat/Mailu-OIDC/tree/2024.06 # @see https://github.com/heviat/Mailu-OIDC/tree/2024.06
docker_source: "{{ 'ghcr.io/heviat' if applications[application_id].oidc.enabled | bool else 'ghcr.io/mailu' }}" docker_source: "{{ 'ghcr.io/heviat' if applications[application_id].oidc.enabled | bool else 'ghcr.io/mailu' }}"

View File

@ -7,7 +7,7 @@
- name: "create {{database_name}} database" - name: "create {{database_name}} database"
include_role: include_role:
name: docker-postgres name: docker-postgres
when: enable_central_database | bool when: applications[application_id].database.central_storage | bool
- name: "include seed-database-to-backup.yml" - name: "include seed-database-to-backup.yml"
include_tasks: "{{ playbook_dir }}/roles/backup-docker-to-local/tasks/seed-database-to-backup.yml" include_tasks: "{{ playbook_dir }}/roles/backup-docker-to-local/tasks/seed-database-to-backup.yml"

View File

@ -1,3 +1,3 @@
application_id: "phpmyadmin" application_id: "phpmyadmin"
database_type: "mariadb" database_type: "mariadb"
database_host: "{{ 'central-' + database_type if enable_central_database}}" database_host: "{{ 'central-' + database_type if applications[application_id].database.central_storage}}"

View File

@ -27,7 +27,7 @@ DB_DATABASE={{database_name}}
DB_USERNAME={{database_username}} DB_USERNAME={{database_username}}
DB_PASSWORD={{database_password}} DB_PASSWORD={{database_password}}
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
MYSQL_ROOT_PASSWORD={{database_password}} MYSQL_ROOT_PASSWORD={{database_password}}
DB_PREFIX=null DB_PREFIX=null
DB_DUMP_PATH='/usr/bin' DB_DUMP_PATH='/usr/bin'

View File

@ -1,4 +1,3 @@
application_id: "snipe_it" application_id: "snipe_it"
database_password: "{{applications.snipe_it.database_password}}" database_password: "{{applications.snipe_it.database_password}}"
database_type: "mariadb" database_type: "mariadb"
# enable_central_database: false For debugging reasons here

View File

@ -1,6 +1,6 @@
# This template needs to be included in docker-compose.yml {# This template needs to be included in docker-compose.yml #}
networks: networks:
{% if enable_central_database | bool and database_type is defined %} {% if applications[application_id].database.central_storage | bool and database_type is defined %}
central_{{ database_type }}: central_{{ database_type }}:
external: true external: true
{% endif %} {% endif %}

View File

@ -1,5 +1,5 @@
# This needs to be included in docker-compose.yml which just contain a database volume {# This needs to be included in docker-compose.yml which just contain a database volume #}
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
volumes: volumes:
database: database:
{% endif %} {% endif %}

View File

@ -1,6 +1,6 @@
# This template needs to be included in docker-compose.yml which contain a database and additional volumes {# This template needs to be included in docker-compose.yml which contain a database and additional volumes #}
volumes: volumes:
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
database: database:
{% endif %} {% endif %}
{{ "\n" }} {{ "\n" }}

View File

@ -1,6 +1,6 @@
{# This template needs to be included in docker-compose.yml containers which depend on a database and additional containers #} {# This template needs to be included in docker-compose.yml containers which depend on a database and additional containers #}
depends_on: depends_on:
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
database: database:
condition: service_healthy condition: service_healthy
{% endif %} {% endif %}

View File

@ -1,6 +1,6 @@
{# This template needs to be included in docker-compose.yml containers, which depend on a database, redis and optional additional volumes #} {# This template needs to be included in docker-compose.yml containers, which depend on a database, redis and optional additional volumes #}
depends_on: depends_on:
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
database: database:
condition: service_healthy condition: service_healthy
{% endif %} {% endif %}

View File

@ -1,5 +1,5 @@
{# This template needs to be included in docker-compose.yml containers, which just depend on a database #} {# This template needs to be included in docker-compose.yml containers, which just depend on a database #}
{% if not enable_central_database | bool %} {% if not applications[application_id].database.central_storage | bool %}
depends_on: depends_on:
database: database:
condition: service_healthy condition: service_healthy

View File

@ -1,6 +1,6 @@
{# This template needs to be included in docker-compose.yml containers #} {# This template needs to be included in docker-compose.yml containers #}
networks: networks:
{% if enable_central_database | bool and database_type is defined %} {% if applications[application_id].database.central_storage | bool and database_type is defined %}
central_{{ database_type }}: central_{{ database_type }}:
{% endif %} {% endif %}
{% if applications[application_id].ldap_enabled|default(false)|bool and applications.ldap.openldap.network.local|bool %} {% if applications[application_id].ldap_enabled|default(false)|bool and applications.ldap.openldap.network.local|bool %}