diff --git a/constructor.yml b/constructor.yml index 45eb6c0d..d0715d3e 100644 --- a/constructor.yml +++ b/constructor.yml @@ -1,9 +1,8 @@ --- -# general setup -- name: general setup + +- name: update device hosts: all become: true - tasks: roles: - role: update when: execute_updates | bool diff --git a/group_vars/all b/group_vars/all index 9e5851e9..945afa6b 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,6 +1,7 @@ # General -verbose: false # Prints well formated debug information -top_domain: "localhost" +verbose: false # Prints well formated debug information +top_domain: "localhost" +backups_folder_path: "/Backups/" # Server Tact Variables @@ -86,6 +87,9 @@ system_maintenance_manipulation_services: ## Total System Maintenance Services system_maintenance_services: "{{ system_maintenance_backup_services + system_maintenance_cleanup_services + system_maintenance_manipulation_services }}" +### Define Variables for Docker Volume Health services +whitelisted_anonymous_docker_volumes: [] + # Webserver Configuration ## Nginx-Specific Path Configurations diff --git a/roles/backup-docker-to-local/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml index d436835a..eb0632b7 100644 --- a/roles/backup-docker-to-local/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -46,7 +46,6 @@ cmd: "python database_entry_seeder.py databases.csv {{docker_compose_project_name}} {{database_host}} {{database_databasename}} {{database_username}} {{database_password}}" chdir: "{{backup_docker_to_local_folder}}" when: > - docker_compose_project_name is defined or database_host is defined or database_databasename is defined or database_username is defined or @@ -59,8 +58,7 @@ owner: root group: root when: > - (docker_compose_project_name is defined or - database_host is defined or + (database_host is defined or database_databasename is defined or database_username is defined or database_password is defined) and diff --git a/roles/docker-akaunting/meta/main.yml b/roles/docker-akaunting/meta/main.yml deleted file mode 100644 index ec2a6059..00000000 --- a/roles/docker-akaunting/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose \ No newline at end of file diff --git a/roles/docker-akaunting/tasks/main.yml b/roles/docker-akaunting/tasks/main.yml index f5f0e389..06e46d21 100644 --- a/roles/docker-akaunting/tasks/main.yml +++ b/roles/docker-akaunting/tasks/main.yml @@ -1,19 +1,13 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 dfe128d5..3afc07e0 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-service-' + database_type + '.yml.j2' %} + application: image: docker.io/akaunting/akaunting:{{version_akaunting}} build: @@ -14,15 +17,10 @@ services: - env/run.env environment: - AKAUNTING_SETUP -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} data: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} \ No newline at end of file + +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-attendize/meta/main.yml deleted file mode 100644 index ec2a6059..00000000 --- a/roles/docker-attendize/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose \ No newline at end of file diff --git a/roles/docker-attendize/tasks/main.yml b/roles/docker-attendize/tasks/main.yml index 542f3dfb..7fea90b4 100644 --- a/roles/docker-attendize/tasks/main.yml +++ b/roles/docker-attendize/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 +14,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 4642d39c..3d5537d1 100644 --- a/roles/docker-attendize/templates/docker-compose.yml.j2 +++ b/roles/docker-attendize/templates/docker-compose.yml.j2 @@ -1,30 +1,29 @@ version: '3.2' services: + +{% include 'templates/docker-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + web: image: attendize_web:latest ports: - "{{http_port}}:80" - #- "8081:443" volumes: - .:/usr/share/nginx/html - .:/var/www - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - maildev - - redis - - worker +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} + maildev: + worker: env_file: - ./.env +{% include 'templates/docker-container-networks.yml.j2' %} + worker: image: attendize_worker:latest - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - maildev - - redis +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} + maildev: +{% include 'templates/docker-container-networks.yml.j2' %} volumes: - .:/usr/share/nginx/html - .:/var/www @@ -33,18 +32,10 @@ services: image: maildev/maildev ports: - "{{ mail_interface_http_port }}:1080" +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} -{% include 'templates/docker-redis-service.yml.j2' %} - -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database - -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} redis: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} \ No newline at end of file + +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-baserow/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-baserow/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-baserow/tasks/main.yml b/roles/docker-baserow/tasks/main.yml index 104a5024..ef07660e 100644 --- a/roles/docker-baserow/tasks/main.yml +++ b/roles/docker-baserow/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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..c9dd7ecb 100644 --- a/roles/docker-baserow/templates/docker-compose.yml.j2 +++ b/roles/docker-baserow/templates/docker-compose.yml.j2 @@ -1,6 +1,11 @@ version: '2' services: + +{% include 'templates/docker-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + baserow: image: baserow/baserow:1.19.1 restart: always @@ -12,5 +17,11 @@ services: - data:/baserow/data ports: - "{{http_port}}:80" -volumes: - data: \ No newline at end of file +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} + +{% include 'templates/docker-compose-volumes.yml.j2' %} + data: + redis: + +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-bigbluebutton/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-bigbluebutton/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-bigbluebutton/tasks/main.yml b/roles/docker-bigbluebutton/tasks/main.yml index be8bfff7..c25d6052 100644 --- a/roles/docker-bigbluebutton/tasks/main.yml +++ b/roles/docker-bigbluebutton/tasks/main.yml @@ -1,4 +1,11 @@ --- +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: load docker compose dependencies + include_role: + name: docker-compose + - name: "include task certbot-matomo.yml" include_tasks: certbot-matomo.yml diff --git a/roles/docker-bigbluebutton/vars/main.yml b/roles/docker-bigbluebutton/vars/main.yml index 03befecd..f59e140a 100644 --- a/roles/docker-bigbluebutton/vars/main.yml +++ b/roles/docker-bigbluebutton/vars/main.yml @@ -1,6 +1,5 @@ -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" +database_host: "postgres" # needs to be fixed +database_databasename: "greenlight-v3" +database_username: "postgres" +database_password: "" \ No newline at end of file diff --git a/roles/docker-discourse/meta/main.yml b/roles/docker-discourse/meta/main.yml deleted file mode 100644 index d3606e63..00000000 --- a/roles/docker-discourse/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- nginx-docker-reverse-proxy diff --git a/roles/docker-discourse/tasks/main.yml b/roles/docker-discourse/tasks/main.yml index 9e7b8642..43988d9f 100644 --- a/roles/docker-discourse/tasks/main.yml +++ b/roles/docker-discourse/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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..b73396ad 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 | bool %} + # 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 | bool %} ## 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/meta/main.yml b/roles/docker-funkwhale/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-funkwhale/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-funkwhale/tasks/main.yml b/roles/docker-funkwhale/tasks/main.yml index ec7197ea..27b3c728 100644 --- a/roles/docker-funkwhale/tasks/main.yml +++ b/roles/docker-funkwhale/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 940becd9..e0996d77 100644 --- a/roles/docker-funkwhale/templates/docker-compose.yml.j2 +++ b/roles/docker-funkwhale/templates/docker-compose.yml.j2 @@ -2,48 +2,41 @@ version: "3" services: -{% include 'templates/docker-redis-service.yml.j2' %} - - env_file: .env +{% include 'templates/docker-service-redis.yml.j2' %} celeryworker: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - postgres -% endif %} - - redis env_file: .env command: celery -A funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY-0} environment: - C_FORCE_ROOT=true volumes: - "data:${MEDIA_ROOT}" +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} + celerybeat: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - postgres -% endif %} - - redis env_file: .env command: celery -A funkwhale_api.taskapp beat --pidfile= -l INFO +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} api: restart: always image: funkwhale/api:${FUNKWHALE_VERSION:-latest} depends_on: - - postgres - - redis env_file: .env volumes: - "data:${MEDIA_ROOT}" #- "${STATIC_ROOT}:${STATIC_ROOT}" ports: - "5000" +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} front: restart: always @@ -61,15 +54,10 @@ services: ports: # override those variables in your .env file if needed - "${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT}:80" +{% include 'templates/docker-container-networks.yml.j2' %} -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} - -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} data: redis: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-gitea/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-gitea/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-gitea/tasks/main.yml b/roles/docker-gitea/tasks/main.yml index a2efdf59..a0266bb3 100644 --- a/roles/docker-gitea/tasks/main.yml +++ b/roles/docker-gitea/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 cb43f04f..03f3e46f 100644 --- a/roles/docker-gitea/templates/docker-compose.yml.j2 +++ b/roles/docker-gitea/templates/docker-compose.yml.j2 @@ -1,6 +1,9 @@ version: '3' services: + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: logging: driver: journald @@ -27,20 +30,10 @@ services: - data:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database - links: - - database -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} data: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} -networks: - default: - driver: bridge +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-gitlab/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-gitlab/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-gitlab/tasks/main.yml b/roles/docker-gitlab/tasks/main.yml index 806daaec..a0266bb3 100644 --- a/roles/docker-gitlab/tasks/main.yml +++ b/roles/docker-gitlab/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 e5fc014b..5a8bbfd5 100644 --- a/roles/docker-gitlab/templates/docker-compose.yml.j2 +++ b/roles/docker-gitlab/templates/docker-compose.yml.j2 @@ -1,5 +1,10 @@ version: '3.6' services: + +{% include 'templates/docker-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + web: image: 'gitlab/gitlab-ee:latest' restart: always @@ -32,24 +37,13 @@ services: - 'logs:/var/log/gitlab' - 'data:/var/opt/gitlab' shm_size: '256m' - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - database: - condition: service_healthy -{% endif %} - redis: +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} -{% include 'templates/docker-redis-service.yml.j2' %} +{% include 'templates/docker-compose-networks.yml.j2' %} -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} - -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} redis: config: logs: data: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} 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/meta/main.yml b/roles/docker-joomla/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-joomla/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-joomla/tasks/main.yml b/roles/docker-joomla/tasks/main.yml index d9bad86f..d2ca459f 100644 --- a/roles/docker-joomla/tasks/main.yml +++ b/roles/docker-joomla/tasks/main.yml @@ -1,15 +1,13 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 ec3707a4..4f9534ca 100644 --- a/roles/docker-joomla/templates/docker-compose.yml.j2 +++ b/roles/docker-joomla/templates/docker-compose.yml.j2 @@ -1,6 +1,9 @@ version: '3' services: + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: image: joomla logging: @@ -11,21 +14,14 @@ services: JOOMLA_DB_PASSWORD: "{{database_password}}" JOOMLA_DB_NAME: "{{database_databasename}}" restart: always -{% if not ( enable_central_database | lower | bool ) %} - links: - - database -{% endif %} volumes: - data:/var/www/html ports: - "127.0.0.1:{{http_port}}:80" +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} data: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} + +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-listmonk/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-listmonk/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-listmonk/tasks/main.yml b/roles/docker-listmonk/tasks/main.yml index 80e3da76..66a0413b 100644 --- a/roles/docker-listmonk/tasks/main.yml +++ b/roles/docker-listmonk/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 3a659b29..4387ca9c 100644 --- a/roles/docker-listmonk/templates/docker-compose.yml.j2 +++ b/roles/docker-listmonk/templates/docker-compose.yml.j2 @@ -2,6 +2,8 @@ version: "3.7" services: +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: restart: unless-stopped image: listmonk/listmonk:latest @@ -11,13 +13,7 @@ services: - TZ=Etc/UTC volumes: - ./config.toml:/listmonk/config.toml +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database - -{% include 'templates/docker-postgres-service.yml.j2' %} - -volumes: - database: -{% endif %} \ No newline at end of file +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-mailu/meta/main.yml index 1240088e..12fe7062 100644 --- a/roles/docker-mailu/meta/main.yml +++ b/roles/docker-mailu/meta/main.yml @@ -1,3 +1,2 @@ dependencies: -- docker-compose - systemd-notifier diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index 4b09d8b2..27a2632a 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml vars: @@ -28,11 +31,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 74eccd20..25b5cbb8 100644 --- a/roles/docker-mailu/templates/docker-compose.yml.j2 +++ b/roles/docker-mailu/templates/docker-compose.yml.j2 @@ -2,27 +2,16 @@ 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-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} # Core services resolver: image: ghcr.io/mailu/unbound:{{version_mailu}} env_file: mailu.env restart: always - networks: +{% include 'templates/docker-container-networks.yml.j2' %} default: ipv4_address: 192.168.203.254 logging: @@ -46,17 +35,13 @@ services: volumes: - "/etc/mailu/overrides/nginx:/overrides:ro" - "/etc/mailu/certs:/certs" - depends_on: +{% include 'templates/docker-container-depends-on-also-database.yml.j2' %} resolver: condition: service_started -{% if not ( enable_central_database | lower | bool ) %} - database: - condition: service_healthy -{% endif %} - networks: - - default - - webmail - - radicale +{% include 'templates/docker-container-networks.yml.j2' %} + default: + webmail: + radicale: dns: - 192.168.203.254 @@ -67,17 +52,15 @@ services: volumes: - "admin_data:/data" - "dkim:/dkim" - depends_on: - - resolver - - front - - redis -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} + resolver: + front: logging: driver: journald dns: - 192.168.203.254 +{% include 'templates/docker-container-networks.yml.j2' %} + imap: image: ghcr.io/mailu/dovecot:{{version_mailu}} restart: always @@ -92,6 +75,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-container-networks.yml.j2' %} smtp: image: ghcr.io/mailu/postfix:{{version_mailu}} @@ -107,6 +91,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-container-networks.yml.j2' %} oletools: image: ghcr.io/mailu/oletools:{{version_mailu}} @@ -116,8 +101,8 @@ services: - resolver dns: - 192.168.203.254 - networks: - - noinet +{% include 'templates/docker-container-networks.yml.j2' %} + noinet: antispam: image: ghcr.io/mailu/rspamd:{{version_mailu}} @@ -134,11 +119,12 @@ services: - resolver dns: - 192.168.203.254 - networks: - - default - - noinet logging: driver: journald +{% include 'templates/docker-container-networks.yml.j2' %} + default: + noinet: + # Optional services antivirus: @@ -153,6 +139,7 @@ services: - 192.168.203.254 logging: driver: journald +{% include 'templates/docker-container-networks.yml.j2' %} webdav: image: ghcr.io/mailu/radicale:{{version_mailu}} @@ -168,6 +155,7 @@ services: - resolver dns: - 192.168.203.254 +{% include 'templates/docker-container-networks.yml.j2' %} fetchmail: image: ghcr.io/mailu/fetchmail:{{version_mailu}} @@ -184,6 +172,7 @@ services: - resolver dns: - 192.168.203.254 +{% include 'templates/docker-container-networks.yml.j2' %} webmail: image: ghcr.io/mailu/webmail:{{version_mailu}} @@ -198,18 +187,12 @@ services: - resolver logging: driver: journald - networks: - - webmail dns: - 192.168.203.254 -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-container-networks.yml.j2' %} + webmail: -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.yml.j2' %} smtp_queue: admin_data: webdav_data: @@ -218,7 +201,8 @@ volumes: dkim: dovecot_mail: redis: -networks: + +{% include 'templates/docker-compose-networks.yml.j2' %} default: driver: bridge ipam: diff --git a/roles/docker-mailu/vars/main.yml b/roles/docker-mailu/vars/main.yml index 28e92259..b036698b 100644 --- a/roles/docker-mailu/vars/main.yml +++ b/roles/docker-mailu/vars/main.yml @@ -1,6 +1,2 @@ docker_compose_project_name: "mailu" -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: "{{mailu_database_password}}" \ No newline at end of file diff --git a/roles/docker-mariadb/README.md b/roles/docker-mariadb/README.md index 8926a33b..f30f189d 100644 --- a/roles/docker-mariadb/README.md +++ b/roles/docker-mariadb/README.md @@ -24,4 +24,4 @@ Configure the role by setting the required variables. These can be set in the pl - `database_password`: The password for the database user. ## Contributing -Contributions to this project are welcome. Please submit issues and pull requests with your suggestions. \ No newline at end of file +Contributions to this project are welcome. Please submit issues and pull requests with your suggestions. diff --git a/roles/docker-mariadb/tasks/main.yml b/roles/docker-mariadb/tasks/main.yml index db699b76..702f1aa3 100644 --- a/roles/docker-mariadb/tasks/main.yml +++ b/roles/docker-mariadb/tasks/main.yml @@ -1,53 +1,66 @@ - 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: Create a volume for MariaDB socket + docker_volume: + name: mariadb_socket + 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: + - central_mariadb_database:/var/lib/mysql published_ports: - - "127.0.0.1:3306:3306" + - "127.0.0.1:3306:3306" # can be that this will be removed if all applications use sockets command: "--transaction-isolation=READ-COMMITTED --binlog-format=ROW" #for nextcloud when: run_once_docker_mariadb is not defined -- name: wait for availability of mariadb +- name: install python-mysqlclient + pacman: + name: python-mysqlclient + state: present + when: run_once_docker_mariadb is not defined + +- name: wait for database wait_for: - host: "127.0.0.1" - port: "3306" - delay: 0 - timeout: 120 + host: 127.0.0.1 + port: 3306 + delay: 10 + timeout: 300 when: run_once_docker_mariadb is not defined - name: create database mysql_db: - name: "{{database_databasename}}" + name: "{{ database_databasename }}" state: present login_user: root - login_password: "{{central_mariadb_root_password}}" + login_password: "{{ central_mariadb_root_password }}" login_host: 127.0.0.1 login_port: 3306 - listen: create database + - name: create database user mysql_user: name: "{{database_username}}" password: "{{database_password}}" + host: "%" priv: '{{database_databasename}}.*:ALL' state: present login_user: root login_password: "{{central_mariadb_root_password}}" login_host: 127.0.0.1 login_port: 3306 - listen: create database - name: run the docker_mariadb tasks once set_fact: diff --git a/roles/docker-mastodon/meta/main.yml b/roles/docker-mastodon/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-mastodon/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-mastodon/tasks/main.yml b/roles/docker-mastodon/tasks/main.yml index 988ff131..8ed0107e 100644 --- a/roles/docker-mastodon/tasks/main.yml +++ b/roles/docker-mastodon/tasks/main.yml @@ -1,15 +1,13 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 0c22ce4c..4d715ca3 100644 --- a/roles/docker-mastodon/templates/docker-compose.yml.j2 +++ b/roles/docker-mastodon/templates/docker-compose.yml.j2 @@ -1,83 +1,56 @@ version: '3' services: -{% include 'templates/docker-redis-service.yml.j2' %} +{% include 'templates/docker-service-redis.yml.j2' %} - networks: - - internal_network +{% include 'templates/docker-service-' + database_type + '.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 | lower | bool ) %} - - database -{% endif %} - - redis +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} volumes: - data:/mastodon/public/system logging: driver: journald +{% include 'templates/docker-container-networks.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 | lower | bool ) %} - - database -{% endif %} - - redis +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} logging: driver: journald +{% include 'templates/docker-container-networks.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 | lower | bool ) %} - - database -{% endif %} - - redis - networks: - - external_network - - internal_network +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} volumes: - data:/mastodon/public/system healthcheck: test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] logging: driver: journald -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-container-networks.yml.j2' %} -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.yml.j2' %} redis: data: -networks: - external_network: - internal_network: - internal: true \ No newline at end of file + +{% include 'templates/docker-compose-networks.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/meta/main.yml b/roles/docker-matomo/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-matomo/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-matomo/tasks/main.yml b/roles/docker-matomo/tasks/main.yml index eb7b25ed..456bb47c 100644 --- a/roles/docker-matomo/tasks/main.yml +++ b/roles/docker-matomo/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 022c018d..862f7bed 100644 --- a/roles/docker-matomo/templates/docker-compose.yml.j2 +++ b/roles/docker-matomo/templates/docker-compose.yml.j2 @@ -1,6 +1,9 @@ version: '3' services: + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: logging: driver: journald @@ -16,17 +19,10 @@ services: MATOMO_DATABASE_DBNAME: "{{database_databasename}}" volumes: - data:/var/www/html -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} -{% endif %} -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.yml.j2' %} data: -networks: - default: - driver: bridge + +{% include 'templates/docker-compose-networks.yml.j2' %} 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/meta/main.yml b/roles/docker-matrix-compose/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-matrix-compose/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-matrix-compose/tasks/main.yml b/roles/docker-matrix-compose/tasks/main.yml index a3e7ed9b..a47090d1 100644 --- a/roles/docker-matrix-compose/tasks/main.yml +++ b/roles/docker-matrix-compose/tasks/main.yml @@ -1,14 +1,12 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 02605f95..58b4f210 100644 --- a/roles/docker-matrix-compose/templates/docker-compose.yml.j2 +++ b/roles/docker-matrix-compose/templates/docker-compose.yml.j2 @@ -1,7 +1,9 @@ version: '3.1' services: - + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + synapse: image: matrixdotorg/synapse:latest restart: always @@ -16,11 +18,8 @@ services: - SYNAPSE_REPORT_STATS=no ports: - "127.0.0.1:{{synapse_http_port}}:8008" -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} element: image: vectorim/element-web:latest @@ -29,6 +28,7 @@ services: - ./element-config.json:/app/config.json ports: - "127.0.0.1:{{element_http_port}}:80" +{% include 'templates/docker-container-networks.yml.j2' %} # bridges #mautrix-telegram: @@ -59,15 +59,11 @@ services: # volumes: # - instagram_bridge_data:/data -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.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 + +{% include 'templates/docker-compose-networks.yml.j2' %} \ 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-mediawiki/tasks/main.yml b/roles/docker-mediawiki/tasks/main.yml index b0b2e0b9..2f82b65c 100644 --- a/roles/docker-mediawiki/tasks/main.yml +++ b/roles/docker-mediawiki/tasks/main.yml @@ -9,7 +9,7 @@ log_driver: journald image: mediawiki restart: always - links: + depends_on: - database volumes: - "mediawiki-data:/var/www/html/" @@ -20,10 +20,10 @@ image: mariadb environment: MYSQL_DATABASE: mediawiki - MYSQL_ROOT_PASSWORD: "{{mediawiki_mysql_user_password}}" + MYSQL_ROOT_PASSWORD: "{{mediawiki_database_password}}" MYSQL_USER: mediawiki - MYSQL_PASSWORD: "{{mediawiki_mysql_user_password}}" + MYSQL_PASSWORD: "{{mediawiki_database_password}}" MARIADB_AUTO_UPGRADE: "1" volumes: - - mediawiki-database:/var/lib/mysql + - database:/var/lib/mysql restart: always diff --git a/roles/docker-mybb/meta/main.yml b/roles/docker-mybb/meta/main.yml deleted file mode 100644 index ec2a6059..00000000 --- a/roles/docker-mybb/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose \ No newline at end of file diff --git a/roles/docker-mybb/tasks/main.yml b/roles/docker-mybb/tasks/main.yml index 01a73412..26b69b16 100644 --- a/roles/docker-mybb/tasks/main.yml +++ b/roles/docker-mybb/tasks/main.yml @@ -1,15 +1,13 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 806a9018..7148bbae 100644 --- a/roles/docker-mybb/templates/docker-compose.yml.j2 +++ b/roles/docker-mybb/templates/docker-compose.yml.j2 @@ -1,5 +1,8 @@ version: '3.8' services: + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: logging: driver: journald @@ -9,10 +12,9 @@ services: restart: always volumes: - data:/var/www/html -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database -{% endif %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} + server: logging: driver: journald @@ -25,16 +27,9 @@ services: volumes: - "{{docker_compose_instance_confd_directory}}:{{target_mount_conf_d_directory}}:ro" - "data:/var/www/html:ro" +{% include 'templates/docker-container-networks.yml.j2' %} -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.yml.j2' %} data: -networks: - default: - driver: bridge \ No newline at end of file + +{% include 'templates/docker-compose-networks.yml.j2' %} \ 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/meta/main.yml b/roles/docker-nextcloud/meta/main.yml deleted file mode 100644 index ec2a6059..00000000 --- a/roles/docker-nextcloud/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose \ No newline at end of file diff --git a/roles/docker-nextcloud/tasks/main.yml b/roles/docker-nextcloud/tasks/main.yml index 18964e5b..e9a0eba5 100644 --- a/roles/docker-nextcloud/tasks/main.yml +++ b/roles/docker-nextcloud/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - name: "include task certbot-matomo.yml" include_tasks: certbot-matomo.yml @@ -20,11 +23,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 6c326e23..b7cbee05 100644 --- a/roles/docker-nextcloud/templates/docker-compose.yml.j2 +++ b/roles/docker-nextcloud/templates/docker-compose.yml.j2 @@ -1,6 +1,11 @@ version: '3' services: + +{% include 'templates/docker-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: image: "nextcloud:{{version_nextcloud}}-fpm-alpine" restart: always @@ -13,12 +18,8 @@ services: MYSQL_USER: "{{database_username}}" MYSQL_PASSWORD: "{{database_password}}" MYSQL_HOST: {{database_host}}:3306 -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database - -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} web: image: nginx:alpine @@ -27,14 +28,11 @@ services: restart: always ports: - "127.0.0.1:{{http_port}}:80" - depends_on: - - application volumes: - "{{path_docker_volumes}}nextcloud/nginx.conf:/etc/nginx/nginx.conf:ro" volumes_from: - application - -{% include 'templates/docker-redis-service.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} cron: image: "nextcloud:{{version_nextcloud}}-fpm-alpine" @@ -44,17 +42,11 @@ services: volumes: - data:/var/www/html entrypoint: /cron.sh - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - redis -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} + +{% include 'templates/docker-compose-volumes.yml.j2' %} data: redis: -networks: - default: - driver: bridge + +{% include 'templates/docker-compose-networks.yml.j2' %} 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/meta/main.yml b/roles/docker-openproject/meta/main.yml deleted file mode 100644 index ec2a6059..00000000 --- a/roles/docker-openproject/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose \ No newline at end of file diff --git a/roles/docker-openproject/tasks/main.yml b/roles/docker-openproject/tasks/main.yml index 59716155..b2c4d340 100644 --- a/roles/docker-openproject/tasks/main.yml +++ b/roles/docker-openproject/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 611a520b..96e50a71 100644 --- a/roles/docker-openproject/templates/docker-compose.yml.j2 +++ b/roles/docker-openproject/templates/docker-compose.yml.j2 @@ -1,21 +1,8 @@ version: "3.7" - -networks: - frontend: - backend: - -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} - data: - -x-op-restart-policy: &restart_policy - restart: unless-stopped -x-op-image: &image - image: openproject/community:${TAG:-13} + x-op-app: &app - <<: [*image, *restart_policy] + restart: unless-stopped + image: openproject/community:${TAG:-13} environment: OPENPROJECT_HTTPS: "${OPENPROJECT_HTTPS}" OPENPROJECT_HOST__NAME: "${OPENPROJECT_HOST__NAME}" @@ -30,26 +17,20 @@ x-op-app: &app IMAP_ENABLED: "${IMAP_ENABLED:-false}" volumes: - "data:/var/openproject/assets" -{% if not ( enable_central_database | lower | bool ) %} - - "database:/var/openproject/pgdata" -{% endif %} + # - "database:/var/openproject/pgdata" services: -{% if not ( enable_central_database | lower | bool ) %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} - networks: - - backend +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} cache: image: memcached - <<: *restart_policy - networks: - - backend + restart: unless-stopped +{% include 'templates/docker-container-networks.yml.j2' %} proxy: - <<: [*image, *restart_policy] + restart: unless-stopped + image: openproject/community:${TAG:-13} command: "./docker/prod/proxy" ports: - "${PORT}:80" @@ -58,26 +39,18 @@ services: OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}" depends_on: - web - networks: - - frontend +{% include 'templates/docker-container-networks.yml.j2' %} volumes: - "data:/var/openproject/assets" -{% if not ( enable_central_database | lower | bool ) %} - - "database:/var/openproject/pgdata" -{% endif %} + # - "database:/var/openproject/pgdata" Should definetly not be necessary here web: <<: *app command: "./docker/prod/web" - networks: - - frontend - - backend - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-also-database.yml.j2' %} + cache: + seeder: labels: - autoheal=true healthcheck: @@ -99,30 +72,26 @@ services: worker: <<: *app command: "./docker/prod/worker" - networks: - - backend - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-also-database.yml.j2' %} + cache: + seeder: cron: <<: *app command: "./docker/prod/cron" - networks: - - backend - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - cache - - seeder +{% include 'templates/docker-container-networks.yml.j2' %} +{% include 'templates/docker-container-depends-on-also-database.yml.j2' %} + cache: + seeder: seeder: <<: *app command: "./docker/prod/seeder" restart: on-failure - networks: - - backend \ No newline at end of file +{% include 'templates/docker-container-networks.yml.j2' %} + +{% include 'templates/docker-compose-networks.yml.j2' %} + +{% include 'templates/docker-compose-volumes.yml.j2' %} + data: \ No newline at end of file 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/meta/main.yml b/roles/docker-peertube/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-peertube/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-peertube/tasks/main.yml b/roles/docker-peertube/tasks/main.yml index a97df60c..34a8fc76 100644 --- a/roles/docker-peertube/tasks/main.yml +++ b/roles/docker-peertube/tasks/main.yml @@ -1,15 +1,13 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 9f0fc721..61beaa4f 100644 --- a/roles/docker-peertube/templates/docker-compose.yml.j2 +++ b/roles/docker-peertube/templates/docker-compose.yml.j2 @@ -1,6 +1,11 @@ version: "3.3" services: + +{% include 'templates/docker-service-redis.yml.j2' %} + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: image: chocobozzz/peertube:production-bullseye env_file: @@ -13,23 +18,13 @@ services: - data:/data - config:/config restart: "always" - depends_on: - - redis -{% if not ( enable_central_database | lower | bool ) %} - - database +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} -{% include 'templates/docker-postgres-service.yml.j2' %} -{% endif %} - -{% include 'templates/docker-redis-service.yml.j2' %} - - env_file: - - .env -volumes: +{% include 'templates/docker-compose-volumes.yml.j2' %} assets: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} data: redis: - config: \ No newline at end of file + config: + +{% include 'templates/docker-compose-networks.yml.j2' %} \ 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/meta/main.yml b/roles/docker-pixelfed/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-pixelfed/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-pixelfed/tasks/main.yml b/roles/docker-pixelfed/tasks/main.yml index 8eb1ae02..ef07660e 100644 --- a/roles/docker-pixelfed/tasks/main.yml +++ b/roles/docker-pixelfed/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 1f8d0780..cedd4707 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-service-' + database_type + '.yml.j2' %} + +{% include 'templates/docker-service-redis.yml.j2' %} + application: image: zknt/pixelfed restart: always @@ -9,16 +14,13 @@ services: env_file: - ./env volumes: - - "application_data:/var/www/storage" + - "data:/var/www/storage" - "bootstrap:/var/www/bootstrap" - "./env:/var/www/.env" ports: - "{{http_port}}:80" - depends_on: -{% if not ( enable_central_database | lower | bool ) %} - - database -{% endif %} - - redis +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} worker: image: zknt/pixelfed restart: always @@ -27,7 +29,7 @@ services: env_file: - ./env volumes: - - "application_data:/var/www/storage" + - "data:/var/www/storage" - "bootstrap:/var/www/bootstrap" - "./env:/var/www/.env" entrypoint: /worker-entrypoint.sh @@ -36,22 +38,13 @@ services: interval: 60s timeout: 5s retries: 1 - depends_on: - - redis - - application -{% if not ( enable_central_database | lower | bool ) %} - - - database +{% include 'templates/docker-container-depends-on-database-redis.yml.j2' %} + application: +{% include 'templates/docker-container-networks.yml.j2' %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} - -{% include 'templates/docker-redis-service.yml.j2' %} - -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.yml.j2' %} redis: - application_data: - bootstrap: \ No newline at end of file + data: + bootstrap: + +{% include 'templates/docker-compose-networks.yml.j2' %} \ 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..181df3f0 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 @@ -34,7 +34,6 @@ login_password: "{{ central_postgres_password }}" login_host: 127.0.0.1 login_port: 5432 - listen: create database - name: Create database user postgresql_user: @@ -47,7 +46,6 @@ login_password: "{{ central_postgres_password }}" login_host: 127.0.0.1 login_port: 5432 - listen: create database - name: Run the docker_postgres tasks once set_fact: diff --git a/roles/docker-roulette-wheel/vars/main.yml b/roles/docker-roulette-wheel/vars/main.yml index 4fc7c771..57f29caa 100644 --- a/roles/docker-roulette-wheel/vars/main.yml +++ b/roles/docker-roulette-wheel/vars/main.yml @@ -1,3 +1,2 @@ docker_compose_project_name: "roulette-wheel" -docker_compose_instance_directory: "{{path_docker_compose_instances}}{{docker_compose_project_name}}/" app_path: "{{docker_compose_instance_directory}}/app/" \ No newline at end of file diff --git a/roles/docker-wordpress/meta/main.yml b/roles/docker-wordpress/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-wordpress/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index 3feb730c..2ab503cc 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -1,5 +1,7 @@ --- - +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml loop: "{{ domains }}" @@ -8,11 +10,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 14ded290..cff1f1b2 100644 --- a/roles/docker-wordpress/templates/docker-compose.yml.j2 +++ b/roles/docker-wordpress/templates/docker-compose.yml.j2 @@ -17,18 +17,10 @@ services: WORDPRESS_DB_NAME: "{{database_databasename}}" volumes: - data:/var/www/html -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} -{% include 'templates/docker-mariadb-service.yml.j2' %} -{% endif %} +{% include 'templates/docker-compose-networks.yml.j2' %} -volumes: -{% if not ( enable_central_database | lower | bool ) %} - database: -{% endif %} +{% include 'templates/docker-compose-volumes.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/meta/main.yml b/roles/docker-yourls/meta/main.yml deleted file mode 100644 index 03045ca5..00000000 --- a/roles/docker-yourls/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- docker-compose diff --git a/roles/docker-yourls/tasks/main.yml b/roles/docker-yourls/tasks/main.yml index eb7b25ed..456bb47c 100644 --- a/roles/docker-yourls/tasks/main.yml +++ b/roles/docker-yourls/tasks/main.yml @@ -1,12 +1,10 @@ --- +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + - 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 b28dcdab..38ae2e87 100644 --- a/roles/docker-yourls/templates/docker-compose.yml.j2 +++ b/roles/docker-yourls/templates/docker-compose.yml.j2 @@ -1,6 +1,9 @@ version: '3' services: + +{% include 'templates/docker-service-' + database_type + '.yml.j2' %} + application: logging: driver: journald @@ -9,22 +12,16 @@ services: ports: - "127.0.0.1:{{http_port}}:80" environment: - YOURLS_DB_HOST: "database:3306" - YOURLS_DB_USER: "yourls" - YOURLS_DB_PASS: "{{yourls_database_password}}" - YOURLS_DB_NAME: "yourls" + YOURLS_DB_HOST: "{{database_host}}" + YOURLS_DB_USER: "{{database_username}}" + YOURLS_DB_PASS: "{{database_password}}" + YOURLS_DB_NAME: "{{database_databasename}}" YOURLS_SITE: "https://{{domain}}" YOURLS_USER: "{{yourls_user}}" YOURLS_PASS: "{{yourls_user_password}}" -{% if not ( enable_central_database | lower | bool ) %} - depends_on: - - database -{% include 'templates/docker-mariadb-service.yml.j2' %} +{% include 'templates/docker-container-depends-on-just-database.yml.j2' %} +{% include 'templates/docker-container-networks.yml.j2' %} -volumes: - database: -{% endif %} -networks: - default: - driver: bridge +{% include 'templates/docker-compose-volumes-just-database.yml.j2' %} +{% include 'templates/docker-compose-networks.yml.j2' %} 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/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index d5d09427..b496f2a9 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -4,6 +4,13 @@ notify: restart nginx when: run_once_nginx is not defined +- name: install nginx-mod-headers-more for matomo + pacman: + name: nginx-mod-headers-more + state: present + notify: restart nginx + when: run_once_nginx is not defined and nginx_matomo_tracking | bool + - name: Ensure nginx configuration directories are present file: path: "{{ item }}" diff --git a/roles/nginx/templates/nginx.conf.j2 b/roles/nginx/templates/nginx.conf.j2 index 02f989cc..d0531d54 100644 --- a/roles/nginx/templates/nginx.conf.j2 +++ b/roles/nginx/templates/nginx.conf.j2 @@ -1,4 +1,7 @@ +{% if nginx_matomo_tracking | bool %} load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so; +{% endif %} + worker_processes auto; events diff --git a/tasks/docker-compose-common.yml b/tasks/docker-compose-common.yml new file mode 100644 index 00000000..2028d40f --- /dev/null +++ b/tasks/docker-compose-common.yml @@ -0,0 +1,11 @@ +- name: include docker vars + include_vars: vars/docker-database-service.yml.j2 + +- name: load docker compose dependencies + include_role: + name: docker-compose + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool \ No newline at end of file diff --git a/templates/docker-compose-networks.yml.j2 b/templates/docker-compose-networks.yml.j2 new file mode 100644 index 00000000..8d760849 --- /dev/null +++ b/templates/docker-compose-networks.yml.j2 @@ -0,0 +1,7 @@ +# This template needs to be included in docker-compose.yml +networks: +{% if enable_central_database | bool %} + central_{{ database_type }}_network: + external: true +{% endif %} + {{docker_compose_project_name}}_network: \ No newline at end of file diff --git a/templates/docker-compose-volumes-just-database.yml.j2 b/templates/docker-compose-volumes-just-database.yml.j2 new file mode 100644 index 00000000..0e80e052 --- /dev/null +++ b/templates/docker-compose-volumes-just-database.yml.j2 @@ -0,0 +1,5 @@ +# This needs to be included in docker-compose.yml which just contain a database volume +{% if not enable_central_database | bool %} +volumes: + database: +{% endif %} \ No newline at end of file diff --git a/templates/docker-compose-volumes.yml.j2 b/templates/docker-compose-volumes.yml.j2 new file mode 100644 index 00000000..ece146f3 --- /dev/null +++ b/templates/docker-compose-volumes.yml.j2 @@ -0,0 +1,5 @@ +# This template needs to be included in docker-compose.yml which contain a database and additional volumes +volumes: +{% if not enable_central_database | bool %} + database: +{% endif %} \ No newline at end of file diff --git a/templates/docker-container-depends-on-also-database.yml.j2 b/templates/docker-container-depends-on-also-database.yml.j2 new file mode 100644 index 00000000..b38b52bd --- /dev/null +++ b/templates/docker-container-depends-on-also-database.yml.j2 @@ -0,0 +1,6 @@ +# This template needs to be included in docker-compose.yml containers which depend on a database and additional containers + depends_on: +{% if not enable_central_database | bool %} + database: + condition: service_healthy +{% endif %} \ No newline at end of file diff --git a/templates/docker-container-depends-on-database-redis.yml.j2 b/templates/docker-container-depends-on-database-redis.yml.j2 new file mode 100644 index 00000000..57ca0edf --- /dev/null +++ b/templates/docker-container-depends-on-database-redis.yml.j2 @@ -0,0 +1,8 @@ +# This template needs to be included in docker-compose.yml contaienrs, which depend on a database, redis and optional additional volumes + depends_on: +{% if not enable_central_database | bool %} + database: + condition: service_healthy +{% endif %} + redis: + condition: service_healthy diff --git a/templates/docker-container-depends-on-just-database.yml.j2 b/templates/docker-container-depends-on-just-database.yml.j2 new file mode 100644 index 00000000..9c41915c --- /dev/null +++ b/templates/docker-container-depends-on-just-database.yml.j2 @@ -0,0 +1,6 @@ +# This template needs to be included in docker-compose.yml contaienrs, which just depend on a database +{% if not enable_central_database | bool %} + depends_on: + database: + condition: service_healthy +{% endif %} \ No newline at end of file diff --git a/templates/docker-container-networks.yml.j2 b/templates/docker-container-networks.yml.j2 new file mode 100644 index 00000000..6d69a2e7 --- /dev/null +++ b/templates/docker-container-networks.yml.j2 @@ -0,0 +1,6 @@ +# This template needs to be included in docker-compose.yml containers + networks: + - {{docker_compose_project_name}}_network +{% if enable_central_database | bool %} + - central_{{ database_type }}_network +{% endif %} \ No newline at end of file diff --git a/templates/docker-mariadb-service.yml.j2 b/templates/docker-service-mariadb.yml.j2 similarity index 73% rename from templates/docker-mariadb-service.yml.j2 rename to templates/docker-service-mariadb.yml.j2 index 16b1f8c2..5f249e37 100644 --- a/templates/docker-mariadb-service.yml.j2 +++ b/templates/docker-service-mariadb.yml.j2 @@ -1,3 +1,5 @@ +# This template needs to be included in docker-compose.yml, which depend on a mariadb database +{% if not enable_central_database | bool %} database: logging: driver: journald @@ -16,4 +18,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-postgres-service.yml.j2 b/templates/docker-service-postgres.yml.j2 similarity index 68% rename from templates/docker-postgres-service.yml.j2 rename to templates/docker-service-postgres.yml.j2 index 049e4d9e..b5159a17 100644 --- a/templates/docker-postgres-service.yml.j2 +++ b/templates/docker-service-postgres.yml.j2 @@ -1,4 +1,5 @@ - +# This template needs to be included in docker-compose.yml, which depend on a postgres database +{% if not enable_central_database | bool %} database: image: postgres:{{database_version}}-alpine environment: @@ -13,6 +14,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-service-redis.yml.j2 similarity index 57% rename from templates/docker-redis-service.yml.j2 rename to templates/docker-service-redis.yml.j2 index bc5c411c..25aee6b8 100644 --- a/templates/docker-redis-service.yml.j2 +++ b/templates/docker-service-redis.yml.j2 @@ -1,3 +1,4 @@ +# This template needs to be included in docker-compose.yml, which depend on redis redis: image: redis:alpine restart: always @@ -9,4 +10,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..6cb15fd2 --- /dev/null +++ b/vars/docker-database-service.yml.j2 @@ -0,0 +1,6 @@ +docker_compose_instance_directory: "{{ path_docker_compose_instances + docker_compose_project_name + '/' }}" +database_host: "{{ 'central-' + database_type if enable_central_database else 'database' }}" +database_databasename: "{{ docker_compose_project_name }}" +database_username: "{{ docker_compose_project_name }}" + +# This will lead to problems with bbb and openproject \ No newline at end of file