Implemented helper role docker-central-database and refactored code

This commit is contained in:
2025-02-04 18:14:37 +01:00
parent cb6a42e97d
commit 5503326ea6
91 changed files with 358 additions and 237 deletions

View File

@@ -12,7 +12,7 @@
- name: docker compose project setup
command:
cmd: docker-compose -p "{{application_id}}" up -d --force-recreate
chdir: "{{docker_compose_instance_directory}}"
chdir: "{{docker_compose.directories.instance}}"
environment:
COMPOSE_HTTP_TIMEOUT: 600
DOCKER_CLIENT_TIMEOUT: 600
@@ -23,7 +23,7 @@
- name: docker compose project build and setup
command:
cmd: docker-compose -p "{{application_id}}" up -d --force-recreate --build
chdir: "{{docker_compose_instance_directory}}"
chdir: "{{docker_compose.directories.instance}}"
environment:
COMPOSE_HTTP_TIMEOUT: 600
DOCKER_CLIENT_TIMEOUT: 600

View File

@@ -1,6 +1,5 @@
- name: "Set global docker_compose_instance_directory: {{ path_docker_compose_instances }}{{ application_id }}/"
set_fact:
docker_compose_instance_directory: "{{ path_docker_compose_instances }}{{ application_id }}/"
- name: "load variables from {{ role_path }}/vars/docker-compose.yml for whole play"
include_vars: "{{ role_path }}/vars/docker-compose.yml"
- name: "Set global domain based on application_id"
set_fact:
@@ -12,17 +11,20 @@
http_port: "{{ ports.localhost.http_ports[application_id] if application_id in ports.localhost.http_ports else None }}"
# Default case: One port exists. Some applications like matrix don't have an default port
- name: "remove {{ docker_compose_instance_directory }} and all its contents"
- name: "remove {{ docker_compose.directories.instance }} and all its contents"
file:
path: "{{ docker_compose_instance_directory }}"
path: "{{ docker_compose.directories.instance }}"
state: absent
when: mode_reset | bool
- name: "create {{docker_compose_instance_directory}}"
# This could lead to problems in docker-compose directories which are based on a git repository
# @todo Verify that this isn't the case. E.g. in accounting
- name: "Create all docker-compose directories (including parent directories)"
file:
path: "{{docker_compose_instance_directory}}"
path: "{{ item.value }}"
state: directory
mode: 0755
mode: '0755'
with_dict: "{{ docker_compose.directories }}"
- name: flush docker service
meta: flush_handlers

View File

@@ -0,0 +1,10 @@
# Private variable for role. Please use docker_compose.directories.instance instead
_docker_compose_directories_instance: "{{ path_docker_compose_instances }}{{ application_id }}/"
# @See https://chatgpt.com/share/67a23d18-fb54-800f-983c-d6d00752b0b4
docker_compose:
directories:
instance: "{{_docker_compose_directories_instance}}" # Folder for docker-compose.yml file
env: "{{_docker_compose_directories_instance}}/.env/" # Folder for env files
services: "{{_docker_compose_directories_instance}}/services/" # Folder for services
volumes: "{{_docker_compose_directories_instance}}/volumes/" # Folder for volumes