From 01d806fae93766456d665f8ca6f5ac5b6ad9840e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 8 Jan 2024 15:14:55 +0100 Subject: [PATCH] Refactored for simplified use of cleanup parameter --- roles/docker-akaunting/tasks/main.yml | 4 ++-- roles/docker-attendize/tasks/main.yml | 4 ++-- roles/docker-baserow/tasks/main.yml | 10 +++------- roles/docker-bigbluebutton/tasks/main.yml | 2 +- roles/docker-discourse/tasks/main.yml | 10 ++-------- roles/docker-funkwhale/tasks/main.yml | 9 ++------- roles/docker-gitea/tasks/main.yml | 9 ++------- roles/docker-gitlab/tasks/main.yml | 9 ++------- roles/docker-joomla/tasks/main.yml | 9 ++------- roles/docker-listmonk/tasks/main.yml | 9 ++------- roles/docker-mailu/tasks/main.yml | 4 ++-- roles/docker-mastodon/tasks/main.yml | 10 ++-------- roles/docker-matomo/tasks/main.yml | 10 ++-------- roles/docker-matrix-compose/tasks/main.yml | 9 ++------- roles/docker-mybb/tasks/main.yml | 4 ++-- roles/docker-nextcloud/tasks/main.yml | 15 ++------------- roles/docker-openproject/tasks/main.yml | 4 ++-- roles/docker-peertube/tasks/main.yml | 9 ++------- roles/docker-pixelfed/tasks/main.yml | 10 ++-------- roles/docker-roulette-wheel/tasks/main.yml | 10 ++-------- roles/docker-wordpress/tasks/main.yml | 10 ++-------- roles/docker-yourls/tasks/main.yml | 10 ++-------- tasks/docker-compose-common.yml | 17 ++++++++++++----- tasks/docker-compose-database.yml | 10 ++++++++++ vars/docker-common.yml.j2 | 1 + ...se-service.yml.j2 => docker-database.yml.j2} | 3 +-- 26 files changed, 68 insertions(+), 143 deletions(-) create mode 100644 tasks/docker-compose-database.yml create mode 100644 vars/docker-common.yml.j2 rename vars/{docker-database-service.yml.j2 => docker-database.yml.j2} (68%) diff --git a/roles/docker-akaunting/tasks/main.yml b/roles/docker-akaunting/tasks/main.yml index 06e46d21..9a8c47e2 100644 --- a/roles/docker-akaunting/tasks/main.yml +++ b/roles/docker-akaunting/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml diff --git a/roles/docker-attendize/tasks/main.yml b/roles/docker-attendize/tasks/main.yml index ea001a88..99191902 100644 --- a/roles/docker-attendize/tasks/main.yml +++ b/roles/docker-attendize/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks to receive attendize certbot certificate" include_tasks: recieve-certbot-certificate.yml diff --git a/roles/docker-baserow/tasks/main.yml b/roles/docker-baserow/tasks/main.yml index ef07660e..0c937ac6 100644 --- a/roles/docker-baserow/tasks/main.yml +++ b/roles/docker-baserow/tasks/main.yml @@ -1,15 +1,11 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 + - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-bigbluebutton/tasks/main.yml b/roles/docker-bigbluebutton/tasks/main.yml index a728d0a7..fbb01373 100644 --- a/roles/docker-bigbluebutton/tasks/main.yml +++ b/roles/docker-bigbluebutton/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: include docker vars - include_vars: vars/docker-database-service.yml.j2 + include_vars: vars/docker-common.yml.j2 - name: load docker compose dependencies include_role: diff --git a/roles/docker-discourse/tasks/main.yml b/roles/docker-discourse/tasks/main.yml index e117be17..3abdb49b 100644 --- a/roles/docker-discourse/tasks/main.yml +++ b/roles/docker-discourse/tasks/main.yml @@ -6,18 +6,12 @@ name: which state: present -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: "Ensure {{docker_compose_project_name}}_default network exists" community.docker.docker_network: name: "{{docker_compose_project_name}}_default" diff --git a/roles/docker-funkwhale/tasks/main.yml b/roles/docker-funkwhale/tasks/main.yml index 27b3c728..bd865b46 100644 --- a/roles/docker-funkwhale/tasks/main.yml +++ b/roles/docker-funkwhale/tasks/main.yml @@ -1,15 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-gitea/tasks/main.yml b/roles/docker-gitea/tasks/main.yml index a0266bb3..3316509a 100644 --- a/roles/docker-gitea/tasks/main.yml +++ b/roles/docker-gitea/tasks/main.yml @@ -1,15 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-gitlab/tasks/main.yml b/roles/docker-gitlab/tasks/main.yml index a0266bb3..3316509a 100644 --- a/roles/docker-gitlab/tasks/main.yml +++ b/roles/docker-gitlab/tasks/main.yml @@ -1,15 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-joomla/tasks/main.yml b/roles/docker-joomla/tasks/main.yml index d2ca459f..96e2da10 100644 --- a/roles/docker-joomla/tasks/main.yml +++ b/roles/docker-joomla/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml @@ -8,11 +8,6 @@ loop_control: loop_var: domain -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-listmonk/tasks/main.yml b/roles/docker-listmonk/tasks/main.yml index 32c40e0d..39388ec4 100644 --- a/roles/docker-listmonk/tasks/main.yml +++ b/roles/docker-listmonk/tasks/main.yml @@ -1,15 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index 4d7a5180..a49d34ce 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml diff --git a/roles/docker-mastodon/tasks/main.yml b/roles/docker-mastodon/tasks/main.yml index 272773d4..24424c5e 100644 --- a/roles/docker-mastodon/tasks/main.yml +++ b/roles/docker-mastodon/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include create-domains.yml" include_tasks: create-domains.yml @@ -8,12 +8,6 @@ loop_control: loop_var: domain -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: copy docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml notify: docker compose project setup diff --git a/roles/docker-matomo/tasks/main.yml b/roles/docker-matomo/tasks/main.yml index 456bb47c..0b92f7c5 100644 --- a/roles/docker-matomo/tasks/main.yml +++ b/roles/docker-matomo/tasks/main.yml @@ -1,16 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: add docker-compose.yml template: src: "docker-compose.yml.j2" diff --git a/roles/docker-matrix-compose/tasks/main.yml b/roles/docker-matrix-compose/tasks/main.yml index a47090d1..ac86d452 100644 --- a/roles/docker-matrix-compose/tasks/main.yml +++ b/roles/docker-matrix-compose/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml @@ -14,11 +14,6 @@ domain: "{{element_domain}}" http_port: "{{element_http_port}}" -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 #- name: "create {{docker_compose_instance_directory}}mautrix_whatsapp" # file: diff --git a/roles/docker-mybb/tasks/main.yml b/roles/docker-mybb/tasks/main.yml index 26b69b16..539073a7 100644 --- a/roles/docker-mybb/tasks/main.yml +++ b/roles/docker-mybb/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks create-proxy-with-domain-replace.yml" include_tasks: create-proxy-with-domain-replace.yml diff --git a/roles/docker-nextcloud/tasks/main.yml b/roles/docker-nextcloud/tasks/main.yml index e9a0eba5..6bd68082 100644 --- a/roles/docker-nextcloud/tasks/main.yml +++ b/roles/docker-nextcloud/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include task certbot-matomo.yml" include_tasks: certbot-matomo.yml @@ -11,23 +11,12 @@ dest: "{{nginx_servers_directory}}{{domain}}.conf" notify: restart nginx -- name: "create {{path_docker_volumes}}nextcloud/" - file: - path: "{{path_docker_volumes}}nextcloud" - state: directory - mode: 0755 - - name: configure nginx.conf template: src: "templates/nginx.conf.j2" dest: "{{path_docker_volumes}}nextcloud/nginx.conf" notify: docker compose project setup -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: add docker-compose.yml template: diff --git a/roles/docker-openproject/tasks/main.yml b/roles/docker-openproject/tasks/main.yml index b2c4d340..c8fbfc8a 100644 --- a/roles/docker-openproject/tasks/main.yml +++ b/roles/docker-openproject/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml diff --git a/roles/docker-peertube/tasks/main.yml b/roles/docker-peertube/tasks/main.yml index 34a8fc76..091cfe86 100644 --- a/roles/docker-peertube/tasks/main.yml +++ b/roles/docker-peertube/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include create-domains.yml" include_tasks: create-domains.yml @@ -8,11 +8,6 @@ loop_control: loop_var: domain -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - name: copy docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml diff --git a/roles/docker-pixelfed/tasks/main.yml b/roles/docker-pixelfed/tasks/main.yml index ef07660e..a1cf4908 100644 --- a/roles/docker-pixelfed/tasks/main.yml +++ b/roles/docker-pixelfed/tasks/main.yml @@ -1,16 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: add docker-compose.yml template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml notify: docker compose project setup diff --git a/roles/docker-roulette-wheel/tasks/main.yml b/roles/docker-roulette-wheel/tasks/main.yml index 7f9dd97b..0c1df337 100644 --- a/roles/docker-roulette-wheel/tasks/main.yml +++ b/roles/docker-roulette-wheel/tasks/main.yml @@ -1,12 +1,6 @@ --- -- name: "include tasks nginx-docker-proxy-domain.yml" - include_tasks: nginx-docker-proxy-domain.yml - -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml - name: pull app repository git: diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index 2ab503cc..167a18c1 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -1,6 +1,6 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml @@ -10,12 +10,6 @@ vars: nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{wordpress_max_upload_size}};" -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: "Transfering upload.ini to {{docker_compose_instance_directory}}" template: src: upload.ini.j2 diff --git a/roles/docker-yourls/tasks/main.yml b/roles/docker-yourls/tasks/main.yml index 456bb47c..0b92f7c5 100644 --- a/roles/docker-yourls/tasks/main.yml +++ b/roles/docker-yourls/tasks/main.yml @@ -1,16 +1,10 @@ --- -- name: "include docker-compose-common.yml" - include_tasks: docker-compose-common.yml +- name: "include docker-compose-database.yml" + include_tasks: docker-compose-database.yml - name: "include tasks nginx-docker-proxy-domain.yml" include_tasks: nginx-docker-proxy-domain.yml -- name: "create {{docker_compose_instance_directory}}" - file: - path: "{{docker_compose_instance_directory}}" - state: directory - mode: 0755 - - name: add docker-compose.yml template: src: "docker-compose.yml.j2" diff --git a/tasks/docker-compose-common.yml b/tasks/docker-compose-common.yml index 2028d40f..4dec416a 100644 --- a/tasks/docker-compose-common.yml +++ b/tasks/docker-compose-common.yml @@ -1,11 +1,18 @@ - name: include docker vars - include_vars: vars/docker-database-service.yml.j2 + include_vars: vars/docker-common.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 +- name: "remove {{ docker_compose_instance_directory }} and all its contents" + file: + path: "{{ docker_compose_instance_directory }}" + state: absent + when: reset_files | bool + +- name: "create {{docker_compose_instance_directory}}" + file: + path: "{{docker_compose_instance_directory}}" + state: directory + mode: 0755 \ No newline at end of file diff --git a/tasks/docker-compose-database.yml b/tasks/docker-compose-database.yml new file mode 100644 index 00000000..019cc506 --- /dev/null +++ b/tasks/docker-compose-database.yml @@ -0,0 +1,10 @@ +- name: include docker vars/docker-database.yml.j2 + include_vars: vars/docker-database.yml.j2 + +- name: "include docker-compose-common.yml" + include_tasks: docker-compose-common.yml + +- name: create central database + include_role: + name: docker-{{database_type}} + when: enable_central_database | bool \ No newline at end of file diff --git a/vars/docker-common.yml.j2 b/vars/docker-common.yml.j2 new file mode 100644 index 00000000..b06ca1b0 --- /dev/null +++ b/vars/docker-common.yml.j2 @@ -0,0 +1 @@ +docker_compose_instance_directory: "{{ path_docker_compose_instances + docker_compose_project_name + '/' }}" \ No newline at end of file diff --git a/vars/docker-database-service.yml.j2 b/vars/docker-database.yml.j2 similarity index 68% rename from vars/docker-database-service.yml.j2 rename to vars/docker-database.yml.j2 index 022ca48c..d92b8590 100644 --- a/vars/docker-database-service.yml.j2 +++ b/vars/docker-database.yml.j2 @@ -1,6 +1,5 @@ -docker_compose_instance_directory: "{{ path_docker_compose_instances + docker_compose_project_name + '/' }}" database_instance: "{{ 'central-' + database_type if enable_central_database else docker_compose_project_name }}" database_host: "{{ 'central-' + database_type if enable_central_database else 'database' }}" -database_name: "{{ docker_compose_project_name }}" +database_name: "{{ docker_compose_project_name }}" database_username: "{{ docker_compose_project_name }}" database_version: "{{ postgres_default_version }}" \ No newline at end of file