From ecb9ad08092e3c45d171945e20e30eeaa88aec8b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 2 Jan 2024 21:13:34 +0100 Subject: [PATCH] Implemented vars, tasks and templates for central database setup until mastodon role --- roles/docker-akaunting/tasks/main.yml | 17 +++-- roles/docker-akaunting/templates/db.env.j2 | 9 --- .../templates/docker-compose.yml.j2 | 17 +++-- roles/docker-akaunting/templates/run.env.j2 | 8 +-- roles/docker-akaunting/vars/main.yml | 5 +- roles/docker-attendize/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 43 +++++------- roles/docker-attendize/vars/main.yml | 5 +- roles/docker-baserow/tasks/main.yml | 8 +++ .../templates/docker-compose.yml.j2 | 13 +++- roles/docker-baserow/templates/env.j2 | 10 +++ roles/docker-baserow/vars/main.yml | 4 +- roles/docker-bigbluebutton/vars/main.yml | 12 ++-- roles/docker-discourse/tasks/main.yml | 8 +++ roles/docker-discourse/templates/app.yml.j2 | 22 ++++-- roles/docker-discourse/vars/main.yml | 5 +- .../templates/docker-compose.yml.j2 | 10 --- roles/docker-funkwhale/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 24 +++---- roles/docker-funkwhale/vars/main.yml | 4 +- roles/docker-gitea/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 15 ++-- roles/docker-gitea/vars/main.yml | 7 +- roles/docker-gitlab/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 8 +-- roles/docker-gitlab/vars/main.yml | 7 +- roles/docker-joomla/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 19 +++-- roles/docker-joomla/vars/main.yml | 7 +- roles/docker-listmonk/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 12 ++-- roles/docker-listmonk/vars/main.yml | 7 +- roles/docker-mailu/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 69 +++++++++---------- roles/docker-mariadb/tasks/main.yml | 8 ++- roles/docker-mastodon/tasks/main.yml | 13 ++-- .../templates/.env.production.j2 | 2 + .../templates/docker-compose.yml.j2 | 54 +++++---------- roles/docker-mastodon/vars/main.yml | 7 +- roles/docker-matomo/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 9 +-- roles/docker-matomo/vars/main.yml | 5 +- roles/docker-matrix-compose/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 11 +-- roles/docker-matrix-compose/vars/main.yml | 8 +-- roles/docker-mybb/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 13 +--- roles/docker-mybb/vars/main.yml | 7 +- roles/docker-nextcloud/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 16 ++--- roles/docker-nextcloud/vars/main.yml | 7 +- roles/docker-openproject/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 35 +++------- roles/docker-openproject/vars/main.yml | 7 +- roles/docker-peertube/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 6 +- roles/docker-peertube/vars/main.yml | 5 +- roles/docker-pixelfed/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 30 +++----- roles/docker-pixelfed/vars/main.yml | 5 +- roles/docker-postgres/tasks/main.yml | 4 +- roles/docker-wordpress/tasks/main.yml | 12 ++-- .../templates/docker-compose.yml.j2 | 9 +-- roles/docker-wordpress/vars/main.yml | 5 +- roles/docker-yourls/tasks/main.yml | 13 ++-- .../templates/docker-compose.yml.j2 | 5 +- roles/docker-yourls/vars/main.yml | 5 +- templates/docker-database-volume.yml.j2 | 3 + .../docker-depends-on-central-database.yml.j2 | 5 ++ templates/docker-mariadb-service.yml.j2 | 6 +- .../docker-network-for-container-add.yml.j2 | 0 .../docker-networks-for-container.yml.j2 | 5 ++ templates/docker-networks-for-role.yml.j2 | 6 ++ templates/docker-postgres-service.yml.j2 | 7 +- templates/docker-redis-service.yml.j2 | 4 +- vars/docker-database-service.yml.j2 | 4 ++ 76 files changed, 431 insertions(+), 467 deletions(-) delete mode 100644 roles/docker-akaunting/templates/db.env.j2 create mode 100644 templates/docker-database-volume.yml.j2 create mode 100644 templates/docker-depends-on-central-database.yml.j2 create mode 100644 templates/docker-network-for-container-add.yml.j2 create mode 100644 templates/docker-networks-for-container.yml.j2 create mode 100644 templates/docker-networks-for-role.yml.j2 create mode 100644 vars/docker-database-service.yml.j2 diff --git a/roles/docker-akaunting/tasks/main.yml b/roles/docker-akaunting/tasks/main.yml index f5f0e389..a2dc4a22 100644 --- a/roles/docker-akaunting/tasks/main.yml +++ b/roles/docker-akaunting/tasks/main.yml @@ -1,19 +1,18 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: Create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "include tasks update-repository-with-docker-compose.yml" include_tasks: update-repository-with-docker-compose.yml -- name: configure db.env - template: src=db.env.j2 dest={{docker_compose_instance_directory}}/env/db.env - notify: docker compose project setup - - name: configure run.env template: src=run.env.j2 dest={{docker_compose_instance_directory}}/env/run.env notify: docker compose project setup diff --git a/roles/docker-akaunting/templates/db.env.j2 b/roles/docker-akaunting/templates/db.env.j2 deleted file mode 100644 index 6065ffbb..00000000 --- a/roles/docker-akaunting/templates/db.env.j2 +++ /dev/null @@ -1,9 +0,0 @@ -# These could be changed -MYSQL_DATABASE={{database_databasename}} -MYSQL_USER={{database_username}} - -# This should definitely be changed to something long and random -MYSQL_PASSWORD={{database_password}} - -# You should probably leave this -MYSQL_ROOT_PASSWORD={{database_password}} diff --git a/roles/docker-akaunting/templates/docker-compose.yml.j2 b/roles/docker-akaunting/templates/docker-compose.yml.j2 index b847cfe4..3d2aaafd 100644 --- a/roles/docker-akaunting/templates/docker-compose.yml.j2 +++ b/roles/docker-akaunting/templates/docker-compose.yml.j2 @@ -1,6 +1,9 @@ version: '3.7' services: + +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} + application: image: docker.io/akaunting/akaunting:{{version_akaunting}} build: @@ -14,15 +17,11 @@ services: - env/run.env environment: - AKAUNTING_SETUP -{% if not enable_central_database %} - depends_on: - - database - -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} volumes: data: -{% if not enable_central_database %} - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-database-volume.yml.j2' %} + +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-akaunting/templates/run.env.j2 b/roles/docker-akaunting/templates/run.env.j2 index ea88b876..df2aea59 100644 --- a/roles/docker-akaunting/templates/run.env.j2 +++ b/roles/docker-akaunting/templates/run.env.j2 @@ -3,12 +3,12 @@ APP_URL=https://{{domain}} LOCALE=en-US # Don't change this unless you rename your database container or use rootless podman, in case of using rootless podman you should set it to 127.0.0.1 (NOT localhost) -DB_HOST=akaunting-db +DB_HOST={{database_host}} # Change these to match env/db.env -DB_DATABASE=akaunting -DB_USERNAME=admin -DB_PASSWORD={{akaunting_database_password}} +DB_DATABASE={{database_databasename}} +DB_USERNAME={{database_username}} +DB_PASSWORD={{database_password}} # You should change this to a random string of three numbers or letters followed by an underscore DB_PREFIX=asd_ diff --git a/roles/docker-akaunting/vars/main.yml b/roles/docker-akaunting/vars/main.yml index 51eed924..9e5c4adf 100644 --- a/roles/docker-akaunting/vars/main.yml +++ b/roles/docker-akaunting/vars/main.yml @@ -1,9 +1,6 @@ docker_compose_project_name: "akaunting" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "admin" +database_type: "mariadb" database_password: "{{akaunting_database_password}}" repository_address: "https://github.com/akaunting/docker.git" diff --git a/roles/docker-attendize/tasks/main.yml b/roles/docker-attendize/tasks/main.yml index 542f3dfb..b223ae77 100644 --- a/roles/docker-attendize/tasks/main.yml +++ b/roles/docker-attendize/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: receive {{ mail_interface_domain }} certificate command: certbot certonly --agree-tos --email {{ administrator_email }} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{ mail_interface_domain }} @@ -11,10 +19,5 @@ dest: "{{nginx_servers_directory}}{{domain}}.conf" notify: restart nginx -- name: Create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "include tasks update-repository-with-docker-compose.yml" include_tasks: update-repository-with-docker-compose.yml \ No newline at end of file diff --git a/roles/docker-attendize/templates/docker-compose.yml.j2 b/roles/docker-attendize/templates/docker-compose.yml.j2 index 2c664ac6..75d8a8f7 100644 --- a/roles/docker-attendize/templates/docker-compose.yml.j2 +++ b/roles/docker-attendize/templates/docker-compose.yml.j2 @@ -4,47 +4,40 @@ services: image: attendize_web:latest ports: - "{{http_port}}:80" - #- "8081:443" volumes: - .:/usr/share/nginx/html - .:/var/www - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - maildev - - redis - - worker +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + maildev: + redis: + worker: env_file: - ./.env +{% include 'templates/docker-networks-for-container.yml.j2' %} + worker: image: attendize_worker:latest - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - maildev - - redis +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + maildev: + redis: +{% include 'templates/docker-networks-for-container.yml.j2' %} volumes: - .:/usr/share/nginx/html - .:/var/www +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} + maildev: image: maildev/maildev ports: - "{{ mail_interface_http_port }}:1080" - +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + {% include 'templates/docker-redis-service.yml.j2' %} -{% if not enable_central_database %} - depends_on: - - database - -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - volumes: redis: -{% if not enable_central_database %} - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-database-volume.yml.j2' %} + +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-attendize/vars/main.yml b/roles/docker-attendize/vars/main.yml index c1fe3e17..3868f140 100644 --- a/roles/docker-attendize/vars/main.yml +++ b/roles/docker-attendize/vars/main.yml @@ -1,11 +1,8 @@ --- docker_compose_project_name: "attendize" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml" mail_interface_domain: "mail.{{domain}}" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{attendize_database_password}}" repository_address: "https://github.com/Attendize/Attendize.git" \ No newline at end of file diff --git a/roles/docker-baserow/tasks/main.yml b/roles/docker-baserow/tasks/main.yml index 104a5024..014b690d 100644 --- a/roles/docker-baserow/tasks/main.yml +++ b/roles/docker-baserow/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml diff --git a/roles/docker-baserow/templates/docker-compose.yml.j2 b/roles/docker-baserow/templates/docker-compose.yml.j2 index a3a0243d..b36e0e63 100644 --- a/roles/docker-baserow/templates/docker-compose.yml.j2 +++ b/roles/docker-baserow/templates/docker-compose.yml.j2 @@ -12,5 +12,16 @@ services: - data:/baserow/data ports: - "{{http_port}}:80" +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + +{% include 'templates/docker-redis-service.yml.j2' %} + +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} + volumes: - data: \ No newline at end of file + data: + redis: +{% include 'templates/docker-database-volume.yml.j2' %} + +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-baserow/templates/env.j2 b/roles/docker-baserow/templates/env.j2 index db4b80c4..5a756e2b 100644 --- a/roles/docker-baserow/templates/env.j2 +++ b/roles/docker-baserow/templates/env.j2 @@ -8,3 +8,13 @@ EMAIL_SMTP_PORT={{ system_email_smtp_port }} EMAIL_SMTP_USER={{ system_email_username }} EMAIL_SMTP_PASSWORD={{ system_email_password }} EMAIL_SMTP_USE_TLS={{ system_email_tls | upper }} + +DATABASE_USER={{ database_username }} +DATABASE_NAME={{ database_databasename }} +DATABASE_HOST={{ database_host }} +DATABASE_PORT=5432 +DATABASE_PASSWORD={{ database_password }} + +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_PASSWORD= diff --git a/roles/docker-baserow/vars/main.yml b/roles/docker-baserow/vars/main.yml index 67efb239..f15802ea 100644 --- a/roles/docker-baserow/vars/main.yml +++ b/roles/docker-baserow/vars/main.yml @@ -1,2 +1,4 @@ docker_compose_project_name: "baserow" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" \ No newline at end of file +database_password: "{{ baserow_database_password }}" +database_version: "{{ baserow_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-bigbluebutton/vars/main.yml b/roles/docker-bigbluebutton/vars/main.yml index 03befecd..e0e5b6db 100644 --- a/roles/docker-bigbluebutton/vars/main.yml +++ b/roles/docker-bigbluebutton/vars/main.yml @@ -1,6 +1,6 @@ -docker_compose_project_name: "bigbluebutton" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "postgres" -database_databasename: "greenlight-v3" -database_username: "postgres" -database_password: "" \ No newline at end of file +docker_compose_project_name: "bigbluebutton" +docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" +database_host: "postgres" +database_databasename: "greenlight-v3" +database_username: "postgres" +database_password: "" \ No newline at end of file diff --git a/roles/docker-discourse/tasks/main.yml b/roles/docker-discourse/tasks/main.yml index 9e7b8642..ba8ad2c7 100644 --- a/roles/docker-discourse/tasks/main.yml +++ b/roles/docker-discourse/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml loop: "{{ domains }}" diff --git a/roles/docker-discourse/templates/app.yml.j2 b/roles/docker-discourse/templates/app.yml.j2 index 659b865d..fe222609 100644 --- a/roles/docker-discourse/templates/app.yml.j2 +++ b/roles/docker-discourse/templates/app.yml.j2 @@ -63,13 +63,21 @@ env: ## TODO: The SMTP mail server used to validate new accounts and send notifications # SMTP ADDRESS, username, and password are required # WARNING the char '#' in SMTP password can cause problems! - DISCOURSE_SMTP_ADDRESS: {{system_email_host}} - DISCOURSE_SMTP_PORT: {{system_email_smtp_port}} - DISCOURSE_SMTP_USER_NAME: {{system_email}} - DISCOURSE_SMTP_PASSWORD: {{system_email_password}} + DISCOURSE_SMTP_ADDRESS: {{ system_email_host }} + DISCOURSE_SMTP_PORT: {{ system_email_smtp_port }} + DISCOURSE_SMTP_USER_NAME: {{ system_email }} + DISCOURSE_SMTP_PASSWORD: {{ system_email_password }} DISCOURSE_SMTP_ENABLE_START_TLS: {{ system_email_start_tls | upper }} - DISCOURSE_SMTP_DOMAIN: {{system_email_domain}} - DISCOURSE_NOTIFICATION_EMAIL: {{system_email}} + DISCOURSE_SMTP_DOMAIN: {{ system_email_domain }} + DISCOURSE_NOTIFICATION_EMAIL: {{ system_email }} + +{% if enable_central_database %} + # Database Configuration + DISCOURSE_DB_USERNAME: {{ database_username }} + DISCOURSE_DB_PASSWORD: {{ database_password }} + DISCOURSE_DB_HOST: {{ database_host }} + DISCOURSE_DB_NAME: {{ database_databasename }} +{% if enable_central_database %} ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate #LETSENCRYPT_ACCOUNT_EMAIL: administrator@veen.world @@ -85,7 +93,7 @@ env: ## The Docker container is stateless; all data is stored in /shared volumes: - volume: - host: discourse_application_data + host: discourse_data guest: /shared - volume: host: /var/discourse/shared/standalone/log/var-log diff --git a/roles/docker-discourse/vars/main.yml b/roles/docker-discourse/vars/main.yml index 024b3cfb..c6d5e00d 100644 --- a/roles/docker-discourse/vars/main.yml +++ b/roles/docker-discourse/vars/main.yml @@ -1 +1,4 @@ -docker_compose_instance_directory: "{{path_docker_compose_instances}}discourse/" +docker_compose_project_name: "attendize" +database_password: "{{ baserow_database_password }}" +database_version: "{{ baserow_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-elk/templates/docker-compose.yml.j2 b/roles/docker-elk/templates/docker-compose.yml.j2 index 2abb0ef5..81c50ce3 100644 --- a/roles/docker-elk/templates/docker-compose.yml.j2 +++ b/roles/docker-elk/templates/docker-compose.yml.j2 @@ -23,8 +23,6 @@ services: # Use single node discovery in order to disable production mode and avoid bootstrap checks. # see: https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html discovery.type: single-node - networks: - - elk logstash: build: @@ -47,8 +45,6 @@ services: - "9600:9600" environment: LS_JAVA_OPTS: "-Xmx256m -Xms256m" - networks: - - elk depends_on: - elasticsearch @@ -64,14 +60,8 @@ services: read_only: true ports: - "127.0.0.1:{{ http_port }}:5601" - networks: - - elk depends_on: - elasticsearch -networks: - elk: - driver: bridge - volumes: elasticsearch: diff --git a/roles/docker-funkwhale/tasks/main.yml b/roles/docker-funkwhale/tasks/main.yml index ec7197ea..59923d32 100644 --- a/roles/docker-funkwhale/tasks/main.yml +++ b/roles/docker-funkwhale/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: Create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-funkwhale/templates/docker-compose.yml.j2 b/roles/docker-funkwhale/templates/docker-compose.yml.j2 index 1cf97f1d..e114e40f 100644 --- a/roles/docker-funkwhale/templates/docker-compose.yml.j2 +++ b/roles/docker-funkwhale/templates/docker-compose.yml.j2 @@ -10,9 +10,7 @@ services: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} depends_on: -{% if not enable_central_database %} - - postgres -% endif %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} - redis env_file: .env command: celery -A funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY-0} @@ -20,23 +18,24 @@ services: - C_FORCE_ROOT=true volumes: - "data:${MEDIA_ROOT}" +{% include 'templates/docker-networks-for-container.yml.j2' %} + celerybeat: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} depends_on: -{% if not enable_central_database %} - - postgres -% endif %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} - redis env_file: .env command: celery -A funkwhale_api.taskapp beat --pidfile= -l INFO +{% include 'templates/docker-networks-for-container.yml.j2' %} api: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} depends_on: - - postgres +{% include 'templates/docker-depends-on-central-database.yml.j2' %} - redis env_file: .env volumes: @@ -44,6 +43,7 @@ services: #- "${STATIC_ROOT}:${STATIC_ROOT}" ports: - "5000" +{% include 'templates/docker-networks-for-container.yml.j2' %} front: restart: always @@ -61,15 +61,13 @@ services: ports: # override those variables in your .env file if needed - "${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT}:80" +{% include 'templates/docker-networks-for-container.yml.j2' %} -{% if not enable_central_database %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} volumes: data: redis: +{% include 'templates/docker-database-volume.yml.j2' %} -{% if not enable_central_database %} - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-funkwhale/vars/main.yml b/roles/docker-funkwhale/vars/main.yml index 407b9deb..93b11fb6 100644 --- a/roles/docker-funkwhale/vars/main.yml +++ b/roles/docker-funkwhale/vars/main.yml @@ -1,7 +1,5 @@ docker_compose_project_name: "funkwhale" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 512M;" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" database_password: "{{funkwhale_database_password}}" database_version: "{{ funkwhale_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-gitea/tasks/main.yml b/roles/docker-gitea/tasks/main.yml index a2efdf59..24849a0a 100644 --- a/roles/docker-gitea/tasks/main.yml +++ b/roles/docker-gitea/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-gitea/templates/docker-compose.yml.j2 b/roles/docker-gitea/templates/docker-compose.yml.j2 index 2150cab0..cfda365e 100644 --- a/roles/docker-gitea/templates/docker-compose.yml.j2 +++ b/roles/docker-gitea/templates/docker-compose.yml.j2 @@ -27,18 +27,11 @@ services: - data:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro -{% if not enable_central_database %} - depends_on: - - database -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} volumes: data: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} -networks: - default: - driver: bridge \ No newline at end of file +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-gitea/vars/main.yml b/roles/docker-gitea/vars/main.yml index badb90ea..2e7014fc 100644 --- a/roles/docker-gitea/vars/main.yml +++ b/roles/docker-gitea/vars/main.yml @@ -1,6 +1,3 @@ docker_compose_project_name: "gitea" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" -database_password: "{{gitea_database_password}}" \ No newline at end of file +database_password: "{{gitea_database_password}}" +database_type: "mariadb" \ No newline at end of file diff --git a/roles/docker-gitlab/tasks/main.yml b/roles/docker-gitlab/tasks/main.yml index 806daaec..24849a0a 100644 --- a/roles/docker-gitlab/tasks/main.yml +++ b/roles/docker-gitlab/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-gitlab/templates/docker-compose.yml.j2 b/roles/docker-gitlab/templates/docker-compose.yml.j2 index 33a85cd9..9997658e 100644 --- a/roles/docker-gitlab/templates/docker-compose.yml.j2 +++ b/roles/docker-gitlab/templates/docker-compose.yml.j2 @@ -41,15 +41,11 @@ services: {% include 'templates/docker-redis-service.yml.j2' %} -{% if not enable_central_database %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} volumes: redis: config: logs: data: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} diff --git a/roles/docker-gitlab/vars/main.yml b/roles/docker-gitlab/vars/main.yml index 7bc995da..ef475572 100644 --- a/roles/docker-gitlab/vars/main.yml +++ b/roles/docker-gitlab/vars/main.yml @@ -1,7 +1,4 @@ docker_compose_project_name: "gitlab" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" database_password: "{{gitlab_database_password}}" -database_version: "{{ gitlab_database_version | default(postgres_default_version) }}" \ No newline at end of file +database_version: "{{ gitlab_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-joomla/tasks/main.yml b/roles/docker-joomla/tasks/main.yml index d9bad86f..82221967 100644 --- a/roles/docker-joomla/tasks/main.yml +++ b/roles/docker-joomla/tasks/main.yml @@ -1,15 +1,18 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml loop: "{{ domains }}" loop_control: loop_var: domain -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-joomla/templates/docker-compose.yml.j2 b/roles/docker-joomla/templates/docker-compose.yml.j2 index 9a9c8594..5c53ad74 100644 --- a/roles/docker-joomla/templates/docker-compose.yml.j2 +++ b/roles/docker-joomla/templates/docker-compose.yml.j2 @@ -11,21 +11,20 @@ services: JOOMLA_DB_PASSWORD: "{{database_password}}" JOOMLA_DB_NAME: "{{database_databasename}}" restart: always -{% if not enable_central_database %} - depends_on: - - database -{% endif %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} volumes: - data:/var/www/html ports: - "127.0.0.1:{{http_port}}:80" +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% if enable_central_database %} + depends_on: + database: -{% if not enable_central_database %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} volumes: data: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} + +{% include 'templates/docker-networks-for-role.yml.j2' %} diff --git a/roles/docker-joomla/vars/main.yml b/roles/docker-joomla/vars/main.yml index 13740a01..3b0f416e 100644 --- a/roles/docker-joomla/vars/main.yml +++ b/roles/docker-joomla/vars/main.yml @@ -1,6 +1,3 @@ docker_compose_project_name: "joomla" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" -database_password: "{{joomla_database_password}}" \ No newline at end of file +database_password: "{{joomla_database_password}}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-listmonk/tasks/main.yml b/roles/docker-listmonk/tasks/main.yml index 80e3da76..e1321ee8 100644 --- a/roles/docker-listmonk/tasks/main.yml +++ b/roles/docker-listmonk/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-listmonk/templates/docker-compose.yml.j2 b/roles/docker-listmonk/templates/docker-compose.yml.j2 index e0a99a89..d10a9700 100644 --- a/roles/docker-listmonk/templates/docker-compose.yml.j2 +++ b/roles/docker-listmonk/templates/docker-compose.yml.j2 @@ -11,13 +11,9 @@ services: - TZ=Etc/UTC volumes: - ./config.toml:/listmonk/config.toml +{% include 'templates/docker-networks-for-container.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} -{% if not enable_central_database %} - depends_on: - - database +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} -{% include 'templates/docker-postgres-service.yml.j2' %} - -volumes: - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-listmonk/vars/main.yml b/roles/docker-listmonk/vars/main.yml index 233838c7..d2346765 100644 --- a/roles/docker-listmonk/vars/main.yml +++ b/roles/docker-listmonk/vars/main.yml @@ -1,7 +1,4 @@ docker_compose_project_name: "listmonk" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" database_password: "{{listmonk_database_password}}" -database_version: "{{ listmonk_database_version | default(postgres_default_version) }}" \ No newline at end of file +database_version: "{{ listmonk_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index a0bbec80..5c946e5d 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml vars: @@ -28,11 +36,6 @@ state: directory mode: 0755 -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: add docker-compose.yml template: src: "docker-compose.yml.j2" diff --git a/roles/docker-mailu/templates/docker-compose.yml.j2 b/roles/docker-mailu/templates/docker-compose.yml.j2 index ce4fded8..2a186997 100644 --- a/roles/docker-mailu/templates/docker-compose.yml.j2 +++ b/roles/docker-mailu/templates/docker-compose.yml.j2 @@ -3,19 +3,8 @@ version: '2.2' services: {% include 'templates/docker-redis-service.yml.j2' %} - env_file: mailu.env - depends_on: - - resolver - dns: - - 192.168.203.254 - depends_on: - - resolver - dns: - - 192.168.203.254 - networks: - - default - - webmail - - radicale + +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} # Core services resolver: @@ -25,6 +14,10 @@ services: networks: default: ipv4_address: 192.168.203.254 + {{docker_compose_project_name}}_network: +{% if enable_central_database %} + central_{{ database_type }}_network: +{% endif %} logging: driver: journald @@ -53,10 +46,10 @@ services: database: condition: service_healthy {% endif %} - networks: - - default - - webmail - - radicale +{% include 'templates/docker-networks-for-container.yml.j2' %} + default: + webmail: + radicale: dns: - 192.168.203.254 @@ -68,16 +61,16 @@ services: - "admin_data:/data" - "dkim:/dkim" depends_on: - - resolver - - front - - redis -{% if not enable_central_database %} - - database -{% endif %} + resolver: + front: + redis: +{% include 'templates/docker-depends-on-central-database.yml.j2' %} logging: driver: journald dns: - 192.168.203.254 +{% include 'templates/docker-networks-for-container.yml.j2' %} + imap: image: ghcr.io/mailu/dovecot:{{version_mailu}} restart: always @@ -92,6 +85,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} smtp: image: ghcr.io/mailu/postfix:{{version_mailu}} @@ -107,6 +101,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} oletools: image: ghcr.io/mailu/oletools:{{version_mailu}} @@ -116,8 +111,8 @@ services: - resolver dns: - 192.168.203.254 - networks: - - noinet +{% include 'templates/docker-networks-for-container.yml.j2' %} + noinet: antispam: image: ghcr.io/mailu/rspamd:{{version_mailu}} @@ -134,11 +129,12 @@ services: - resolver dns: - 192.168.203.254 - networks: - - default - - noinet logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} + default: + noinet: + # Optional services antivirus: @@ -153,6 +149,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} webdav: image: ghcr.io/mailu/radicale:{{version_mailu}} @@ -168,6 +165,7 @@ services: - resolver dns: - 192.168.203.254 +{% include 'templates/docker-networks-for-container.yml.j2' %} fetchmail: image: ghcr.io/mailu/fetchmail:{{version_mailu}} @@ -184,6 +182,7 @@ services: - resolver dns: - 192.168.203.254 +{% include 'templates/docker-networks-for-container.yml.j2' %} webmail: image: ghcr.io/mailu/webmail:{{version_mailu}} @@ -198,18 +197,13 @@ services: - resolver logging: driver: journald - networks: - - webmail dns: - 192.168.203.254 -{% if not enable_central_database %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-networks-for-container.yml.j2' %} + webmail: volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} smtp_queue: admin_data: webdav_data: @@ -218,7 +212,8 @@ volumes: dkim: dovecot_mail: redis: -networks: + +{% include 'templates/docker-networks-for-role.yml.j2' %} default: driver: bridge ipam: diff --git a/roles/docker-mariadb/tasks/main.yml b/roles/docker-mariadb/tasks/main.yml index db699b76..b7deeb7c 100644 --- a/roles/docker-mariadb/tasks/main.yml +++ b/roles/docker-mariadb/tasks/main.yml @@ -1,19 +1,21 @@ - name: Create Docker network for MariaDB docker_network: - name: mariadb_network + name: central_mariadb_network state: present when: run_once_docker_mariadb is not defined - name: install MariaDB docker_container: - name: mariadb + name: central-mariadb image: mariadb:latest #could lead to problems with nextcloud detach: yes env: MARIADB_ROOT_PASSWORD: "{{central_mariadb_root_password}}" MARIADB_AUTO_UPGRADE: "1" networks: - - name: mariadb_network + - name: central_mariadb_network + volumes: + - database:/var/lib/mysql published_ports: - "127.0.0.1:3306:3306" command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud diff --git a/roles/docker-mastodon/tasks/main.yml b/roles/docker-mastodon/tasks/main.yml index 988ff131..91fe0f8d 100644 --- a/roles/docker-mastodon/tasks/main.yml +++ b/roles/docker-mastodon/tasks/main.yml @@ -1,15 +1,18 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include create-domains.yml" include_tasks: create-domains.yml loop: "{{ domains }}" loop_control: loop_var: domain -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-mastodon/templates/.env.production.j2 b/roles/docker-mastodon/templates/.env.production.j2 index aedacfed..7a772a03 100644 --- a/roles/docker-mastodon/templates/.env.production.j2 +++ b/roles/docker-mastodon/templates/.env.production.j2 @@ -10,9 +10,11 @@ DB_PORT=5432 DB_NAME={{database_databasename}} DB_USER={{database_username}} DB_PASS={{database_password}} + REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD= + SMTP_SERVER={{system_email_host}} SMTP_PORT={{system_email_smtp_port}} SMTP_LOGIN={{system_email_username}} diff --git a/roles/docker-mastodon/templates/docker-compose.yml.j2 b/roles/docker-mastodon/templates/docker-compose.yml.j2 index d3cf97de..c5fb0b02 100644 --- a/roles/docker-mastodon/templates/docker-compose.yml.j2 +++ b/roles/docker-mastodon/templates/docker-compose.yml.j2 @@ -3,81 +3,63 @@ services: {% include 'templates/docker-redis-service.yml.j2' %} - networks: - - internal_network +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} web: image: tootsuite/mastodon:{{version_mastodon}} restart: always env_file: .env.production command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" - networks: - - external_network - - internal_network healthcheck: - # prettier-ignore test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1'] ports: - "127.0.0.1:{{http_port}}:3000" depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - redis +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: + condition: service_healthy volumes: - data:/mastodon/public/system logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} + streaming: image: tootsuite/mastodon:{{version_mastodon}} restart: always env_file: .env.production command: node ./streaming - networks: - - external_network - - internal_network healthcheck: - # prettier-ignore test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1'] ports: - "127.0.0.1:{{stream_port}}:4000" - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - redis +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: + condition: service_healthy logging: driver: journald +{% include 'templates/docker-networks-for-container.yml.j2' %} + sidekiq: image: tootsuite/mastodon:{{version_mastodon}} restart: always env_file: .env.production command: bundle exec sidekiq depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - redis - networks: - - external_network - - internal_network +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: + condition: service_healthy volumes: - data:/mastodon/public/system healthcheck: test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] logging: driver: journald -{% if not enable_central_database %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-networks-for-container.yml.j2' %} volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} redis: data: -networks: - external_network: - internal_network: - internal: true \ No newline at end of file + +{% include 'templates/docker-networks-for-role.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-mastodon/vars/main.yml b/roles/docker-mastodon/vars/main.yml index 9b10f8be..c1109043 100644 --- a/roles/docker-mastodon/vars/main.yml +++ b/roles/docker-mastodon/vars/main.yml @@ -1,7 +1,4 @@ docker_compose_project_name: "mastodon" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" database_password: "{{mastodon_database_password}}" -database_version: "{{ mastodon_database_version | default(postgres_default_version) }}" \ No newline at end of file +database_version: "{{ mastodon_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-matomo/tasks/main.yml b/roles/docker-matomo/tasks/main.yml index eb7b25ed..c3181163 100644 --- a/roles/docker-matomo/tasks/main.yml +++ b/roles/docker-matomo/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-matomo/templates/docker-compose.yml.j2 b/roles/docker-matomo/templates/docker-compose.yml.j2 index c9749067..877a8214 100644 --- a/roles/docker-matomo/templates/docker-compose.yml.j2 +++ b/roles/docker-matomo/templates/docker-compose.yml.j2 @@ -19,14 +19,9 @@ services: {% if not enable_central_database %} depends_on: - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} {% endif %} volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} data: -networks: - default: - driver: bridge diff --git a/roles/docker-matomo/vars/main.yml b/roles/docker-matomo/vars/main.yml index c3ffd341..28fc6e46 100644 --- a/roles/docker-matomo/vars/main.yml +++ b/roles/docker-matomo/vars/main.yml @@ -1,7 +1,4 @@ --- docker_compose_project_name: "matomo" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{matomo_database_password}}" \ No newline at end of file diff --git a/roles/docker-matrix-compose/tasks/main.yml b/roles/docker-matrix-compose/tasks/main.yml index a3e7ed9b..6fd4b598 100644 --- a/roles/docker-matrix-compose/tasks/main.yml +++ b/roles/docker-matrix-compose/tasks/main.yml @@ -1,14 +1,17 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml vars: domain: "{{synapse_domain}}" http_port: "{{synapse_http_port}}" - -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml diff --git a/roles/docker-matrix-compose/templates/docker-compose.yml.j2 b/roles/docker-matrix-compose/templates/docker-compose.yml.j2 index 27f12f8a..0eb84e32 100644 --- a/roles/docker-matrix-compose/templates/docker-compose.yml.j2 +++ b/roles/docker-matrix-compose/templates/docker-compose.yml.j2 @@ -19,7 +19,7 @@ services: {% if not enable_central_database %} depends_on: - database -{% include 'templates/docker-postgres-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} {% endif %} element: @@ -60,14 +60,9 @@ services: # - instagram_bridge_data:/data volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} synapse_data: #telegram_bridge_data: #whatsapp_bridge_data: #facebook_bridge_data: - #instagram_bridge_data: -networks: - default: - driver: bridge \ No newline at end of file + #instagram_bridge_data: \ No newline at end of file diff --git a/roles/docker-matrix-compose/vars/main.yml b/roles/docker-matrix-compose/vars/main.yml index b2b0a5c4..a12a70a2 100644 --- a/roles/docker-matrix-compose/vars/main.yml +++ b/roles/docker-matrix-compose/vars/main.yml @@ -1,7 +1,5 @@ --- docker_compose_project_name: "matrix" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" -database_password: "{{matrix_database_password}}" \ No newline at end of file +database_password: "{{matrix_database_password}}" +database_version: "{{ baserow_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-mybb/tasks/main.yml b/roles/docker-mybb/tasks/main.yml index 01a73412..7bf9aa24 100644 --- a/roles/docker-mybb/tasks/main.yml +++ b/roles/docker-mybb/tasks/main.yml @@ -1,15 +1,18 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks create-proxy-with-domain-replace.yml" include_tasks: create-proxy-with-domain-replace.yml loop: "{{ domains + [source_domain] }}" loop_control: loop_var: domain -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_confd_directory}} and parent directories" file: path: "{{docker_compose_instance_confd_directory}}" diff --git a/roles/docker-mybb/templates/docker-compose.yml.j2 b/roles/docker-mybb/templates/docker-compose.yml.j2 index 6a300ebf..54adad97 100644 --- a/roles/docker-mybb/templates/docker-compose.yml.j2 +++ b/roles/docker-mybb/templates/docker-compose.yml.j2 @@ -26,15 +26,8 @@ services: - "{{docker_compose_instance_confd_directory}}:{{target_mount_conf_d_directory}}:ro" - "data:/var/www/html:ro" -{% if not enable_central_database %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} volumes: -{% if not enable_central_database %} - database: -{% endif %} - data: -networks: - default: - driver: bridge \ No newline at end of file +{% include 'templates/docker-database-volume.yml.j2' %} + data: \ No newline at end of file diff --git a/roles/docker-mybb/vars/main.yml b/roles/docker-mybb/vars/main.yml index 5f33c8a7..6e7c4875 100644 --- a/roles/docker-mybb/vars/main.yml +++ b/roles/docker-mybb/vars/main.yml @@ -1,11 +1,8 @@ --- docker_compose_project_name: "mybb" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" docker_compose_instance_confd_directory: "{{docker_compose_instance_directory}}conf.d/" docker_compose_instance_confd_defaultconf_file: "{{docker_compose_instance_confd_directory}}default.conf" target_mount_conf_d_directory: "{{nginx_servers_directory}}" source_domain: "mybb.{{top_domain}}" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" -database_password: "{{mybb_database_password}}" \ No newline at end of file +database_password: "{{mybb_database_password}}" +database_type: "mariadb" \ No newline at end of file diff --git a/roles/docker-nextcloud/tasks/main.yml b/roles/docker-nextcloud/tasks/main.yml index 18964e5b..eca8f058 100644 --- a/roles/docker-nextcloud/tasks/main.yml +++ b/roles/docker-nextcloud/tasks/main.yml @@ -1,4 +1,12 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include task certbot-matomo.yml" include_tasks: certbot-matomo.yml @@ -20,11 +28,6 @@ dest: "{{path_docker_volumes}}nextcloud/nginx.conf" notify: docker compose project setup -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-nextcloud/templates/docker-compose.yml.j2 b/roles/docker-nextcloud/templates/docker-compose.yml.j2 index 112c762c..e31f3bfe 100644 --- a/roles/docker-nextcloud/templates/docker-compose.yml.j2 +++ b/roles/docker-nextcloud/templates/docker-compose.yml.j2 @@ -17,7 +17,7 @@ services: depends_on: - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} {% endif %} web: @@ -44,17 +44,9 @@ services: volumes: - data:/var/www/html entrypoint: /cron.sh - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - redis +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} data: redis: -networks: - default: - driver: bridge diff --git a/roles/docker-nextcloud/vars/main.yml b/roles/docker-nextcloud/vars/main.yml index adf44477..d050d4b6 100644 --- a/roles/docker-nextcloud/vars/main.yml +++ b/roles/docker-nextcloud/vars/main.yml @@ -1,7 +1,4 @@ --- docker_compose_project_name: "nextcloud" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" -database_password: "{{nextcloud_database_password}}" \ No newline at end of file +database_password: "{{nextcloud_database_password}}" +database_type: "mariadb" \ No newline at end of file diff --git a/roles/docker-openproject/tasks/main.yml b/roles/docker-openproject/tasks/main.yml index 59716155..486446de 100644 --- a/roles/docker-openproject/tasks/main.yml +++ b/roles/docker-openproject/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - - name: "include tasks update-repository-with-docker-compose.yml" include_tasks: update-repository-with-docker-compose.yml diff --git a/roles/docker-openproject/templates/docker-compose.yml.j2 b/roles/docker-openproject/templates/docker-compose.yml.j2 index 0b38061e..8c2fab30 100644 --- a/roles/docker-openproject/templates/docker-compose.yml.j2 +++ b/roles/docker-openproject/templates/docker-compose.yml.j2 @@ -5,9 +5,7 @@ networks: backend: volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} data: x-op-restart-policy: &restart_policy @@ -36,9 +34,7 @@ x-op-app: &app services: -{% if not enable_central_database %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} networks: - backend @@ -72,12 +68,9 @@ services: networks: - frontend - backend - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + cache: + seeder: labels: - autoheal=true healthcheck: @@ -101,24 +94,18 @@ services: command: "./docker/prod/worker" networks: - backend - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + cache: + seeder: cron: <<: *app command: "./docker/prod/cron" networks: - backend - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + cache: + seeder: seeder: <<: *app diff --git a/roles/docker-openproject/vars/main.yml b/roles/docker-openproject/vars/main.yml index dd549717..a7bf3353 100644 --- a/roles/docker-openproject/vars/main.yml +++ b/roles/docker-openproject/vars/main.yml @@ -3,8 +3,7 @@ repository_directory: "{{ path_docker_compose_instances }}{{docker docker_compose_instance_directory: "{{repository_directory}}compose/" docker_compose_file_path: "{{docker_compose_instance_directory}}docker-compose.yml" docker_compose_backup_path: "/tmp/{{docker_compose_project_name}}-docker-compose-backup.yml" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "postgres" database_password: "{{openproject_database_password}}" -repository_address: "https://github.com/opf/openproject-deploy" \ No newline at end of file +repository_address: "https://github.com/opf/openproject-deploy" +database_version: "{{ openproject_database_version | default(postgres_default_version) }}" +database_type: "postgres" \ No newline at end of file diff --git a/roles/docker-peertube/tasks/main.yml b/roles/docker-peertube/tasks/main.yml index a97df60c..9ec5b724 100644 --- a/roles/docker-peertube/tasks/main.yml +++ b/roles/docker-peertube/tasks/main.yml @@ -1,15 +1,18 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include create-domains.yml" include_tasks: create-domains.yml loop: "{{ domains }}" loop_control: loop_var: domain -- name: create database in central Postgres - include_role: - name: docker-postgres - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-peertube/templates/docker-compose.yml.j2 b/roles/docker-peertube/templates/docker-compose.yml.j2 index 35a22df7..1c1fcb4c 100644 --- a/roles/docker-peertube/templates/docker-compose.yml.j2 +++ b/roles/docker-peertube/templates/docker-compose.yml.j2 @@ -18,7 +18,7 @@ services: {% if not enable_central_database %} - database -{% include 'templates/docker-postgres-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} {% endif %} {% include 'templates/docker-redis-service.yml.j2' %} @@ -27,9 +27,7 @@ services: - .env volumes: assets: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} data: redis: config: \ No newline at end of file diff --git a/roles/docker-peertube/vars/main.yml b/roles/docker-peertube/vars/main.yml index bc8c98d6..8add9bfe 100644 --- a/roles/docker-peertube/vars/main.yml +++ b/roles/docker-peertube/vars/main.yml @@ -1,6 +1,3 @@ docker_compose_project_name: "peertube" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{peertube_database_password}}" \ No newline at end of file diff --git a/roles/docker-pixelfed/tasks/main.yml b/roles/docker-pixelfed/tasks/main.yml index 8eb1ae02..014b690d 100644 --- a/roles/docker-pixelfed/tasks/main.yml +++ b/roles/docker-pixelfed/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-pixelfed/templates/docker-compose.yml.j2 b/roles/docker-pixelfed/templates/docker-compose.yml.j2 index a8f471fa..6bf2e273 100644 --- a/roles/docker-pixelfed/templates/docker-compose.yml.j2 +++ b/roles/docker-pixelfed/templates/docker-compose.yml.j2 @@ -1,6 +1,11 @@ version: '2' services: + +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} + +{% include 'templates/docker-redis-service.yml.j2' %} + application: image: zknt/pixelfed restart: always @@ -14,11 +19,8 @@ services: - "./env:/var/www/.env" ports: - "{{http_port}}:80" - depends_on: -{% if not enable_central_database %} - - database -{% endif %} - - redis +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: worker: image: zknt/pixelfed restart: always @@ -36,22 +38,12 @@ services: interval: 60s timeout: 5s retries: 1 - depends_on: - - redis - - application -{% if not enable_central_database %} - - - database - -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -{% include 'templates/docker-redis-service.yml.j2' %} +{% include 'templates/docker-depends-on-central-database.yml.j2' %} + redis: + application: volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} redis: application_data: bootstrap: \ No newline at end of file diff --git a/roles/docker-pixelfed/vars/main.yml b/roles/docker-pixelfed/vars/main.yml index 09caeed8..0409d38c 100644 --- a/roles/docker-pixelfed/vars/main.yml +++ b/roles/docker-pixelfed/vars/main.yml @@ -1,7 +1,4 @@ docker_compose_project_name: "pixelfed" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size 512M;" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{pixelfed_database_password}}" diff --git a/roles/docker-postgres/tasks/main.yml b/roles/docker-postgres/tasks/main.yml index f8771b43..624dda86 100644 --- a/roles/docker-postgres/tasks/main.yml +++ b/roles/docker-postgres/tasks/main.yml @@ -1,6 +1,6 @@ - name: Create Docker network for PostgreSQL docker_network: - name: postgres_network + name: central_postgres_network state: present when: run_once_docker_postgres is not defined @@ -13,7 +13,7 @@ POSTGRES_PASSWORD: "{{ central_postgres_password }}" POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C" # Necessary for docker-matrix networks: - - name: postgres_network + - name: central_postgres_network published_ports: - "127.0.0.1:5432:5432" when: run_once_docker_postgres is not defined diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index 3feb730c..81ded561 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -1,4 +1,11 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml @@ -8,11 +15,6 @@ vars: nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{wordpress_max_upload_size}};" -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-wordpress/templates/docker-compose.yml.j2 b/roles/docker-wordpress/templates/docker-compose.yml.j2 index 73f80ea4..ca00691d 100644 --- a/roles/docker-wordpress/templates/docker-compose.yml.j2 +++ b/roles/docker-wordpress/templates/docker-compose.yml.j2 @@ -21,14 +21,9 @@ services: depends_on: - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} {% endif %} volumes: -{% if not enable_central_database %} - database: -{% endif %} +{% include 'templates/docker-database-volume.yml.j2' %} data: -networks: - default: - driver: bridge diff --git a/roles/docker-wordpress/vars/main.yml b/roles/docker-wordpress/vars/main.yml index 96b4ff0e..d6efe84f 100644 --- a/roles/docker-wordpress/vars/main.yml +++ b/roles/docker-wordpress/vars/main.yml @@ -1,7 +1,4 @@ docker_compose_project_name: "wordpress" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" wordpress_max_upload_size: "64M" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{wordpress_database_password}}" \ No newline at end of file diff --git a/roles/docker-yourls/tasks/main.yml b/roles/docker-yourls/tasks/main.yml index eb7b25ed..c3181163 100644 --- a/roles/docker-yourls/tasks/main.yml +++ b/roles/docker-yourls/tasks/main.yml @@ -1,12 +1,15 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: create database in central MariaDB - include_role: - name: docker-mariadb - when: enable_central_database | bool - - name: "create {{docker_compose_instance_directory}}" file: path: "{{docker_compose_instance_directory}}" diff --git a/roles/docker-yourls/templates/docker-compose.yml.j2 b/roles/docker-yourls/templates/docker-compose.yml.j2 index 9c271134..53acf9fd 100644 --- a/roles/docker-yourls/templates/docker-compose.yml.j2 +++ b/roles/docker-yourls/templates/docker-compose.yml.j2 @@ -20,11 +20,8 @@ services: depends_on: - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-{{ database_type }}-service.yml.j2' %} volumes: database: {% endif %} -networks: - default: - driver: bridge diff --git a/roles/docker-yourls/vars/main.yml b/roles/docker-yourls/vars/main.yml index 29f0fee5..d9d168b3 100644 --- a/roles/docker-yourls/vars/main.yml +++ b/roles/docker-yourls/vars/main.yml @@ -1,6 +1,3 @@ docker_compose_project_name: "yourls" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" -database_host: "database" -database_databasename: "{{docker_compose_project_name}}" -database_username: "{{docker_compose_project_name}}" +database_type: "mariadb" database_password: "{{yourls_database_password}}" \ No newline at end of file diff --git a/templates/docker-database-volume.yml.j2 b/templates/docker-database-volume.yml.j2 new file mode 100644 index 00000000..22b28050 --- /dev/null +++ b/templates/docker-database-volume.yml.j2 @@ -0,0 +1,3 @@ +{% if not enable_central_database %} + database: +{% endif %} \ No newline at end of file diff --git a/templates/docker-depends-on-central-database.yml.j2 b/templates/docker-depends-on-central-database.yml.j2 new file mode 100644 index 00000000..d1b446a8 --- /dev/null +++ b/templates/docker-depends-on-central-database.yml.j2 @@ -0,0 +1,5 @@ +{% if enable_central_database %} + depends_on: + database: + condition: service_healthy +{% endif %} \ No newline at end of file diff --git a/templates/docker-mariadb-service.yml.j2 b/templates/docker-mariadb-service.yml.j2 index 16b1f8c2..5c4fb462 100644 --- a/templates/docker-mariadb-service.yml.j2 +++ b/templates/docker-mariadb-service.yml.j2 @@ -1,3 +1,4 @@ +{% if not enable_central_database %} database: logging: driver: journald @@ -16,4 +17,7 @@ test: "/usr/bin/mariadb --user={{database_username}} --password={{database_password}} --execute \"SHOW DATABASES;\"" interval: 3s timeout: 1s - retries: 5 \ No newline at end of file + retries: 5 + networks: + - {{docker_compose_project_name}}_network +{% endif %} \ No newline at end of file diff --git a/templates/docker-network-for-container-add.yml.j2 b/templates/docker-network-for-container-add.yml.j2 new file mode 100644 index 00000000..e69de29b diff --git a/templates/docker-networks-for-container.yml.j2 b/templates/docker-networks-for-container.yml.j2 new file mode 100644 index 00000000..3596e57b --- /dev/null +++ b/templates/docker-networks-for-container.yml.j2 @@ -0,0 +1,5 @@ + networks: + - {{docker_compose_project_name}}_network +{% if enable_central_database %} + - central_{{ database_type }}_network +{% endif %} \ No newline at end of file diff --git a/templates/docker-networks-for-role.yml.j2 b/templates/docker-networks-for-role.yml.j2 new file mode 100644 index 00000000..b2a00705 --- /dev/null +++ b/templates/docker-networks-for-role.yml.j2 @@ -0,0 +1,6 @@ +networks: +{% if enable_central_database %} + central_{{ database_type }}_network: + external: true +{% endif %} + {{docker_compose_project_name}}_network: \ No newline at end of file diff --git a/templates/docker-postgres-service.yml.j2 b/templates/docker-postgres-service.yml.j2 index 049e4d9e..ebc4018b 100644 --- a/templates/docker-postgres-service.yml.j2 +++ b/templates/docker-postgres-service.yml.j2 @@ -1,4 +1,4 @@ - +{% if not enable_central_database %} database: image: postgres:{{database_version}}-alpine environment: @@ -13,6 +13,9 @@ timeout: 5s retries: 6 volumes: - - type: volume + - type: volume source: database target: /var/lib/postgresql/data + networks: + - {{docker_compose_project_name}}_network +{% endif %} \ No newline at end of file diff --git a/templates/docker-redis-service.yml.j2 b/templates/docker-redis-service.yml.j2 index bc5c411c..6d951751 100644 --- a/templates/docker-redis-service.yml.j2 +++ b/templates/docker-redis-service.yml.j2 @@ -9,4 +9,6 @@ test: ["CMD", "redis-cli", "ping"] interval: 1s timeout: 3s - retries: 30 \ No newline at end of file + retries: 30 + networks: + - {{docker_compose_project_name}}_network \ No newline at end of file diff --git a/vars/docker-database-service.yml.j2 b/vars/docker-database-service.yml.j2 new file mode 100644 index 00000000..cd3cb58e --- /dev/null +++ b/vars/docker-database-service.yml.j2 @@ -0,0 +1,4 @@ +docker_compose_instance_directory: "{{ docker_compose_instance_directory | default(path_docker_compose_instances + docker_compose_project_name + '/') }}" +database_host: "{{ database_host | default('database') }}" +database_databasename: "{{ database_databasename | default(docker_compose_project_name) }}" +database_username: "{{ database_username | default(docker_compose_project_name) }}" \ No newline at end of file