From 85aa718480224c61ddead116dadc82627dd9d2be Mon Sep 17 00:00:00 2001 From: Sam Al-Sapti Date: Sat, 30 Sep 2023 16:42:16 +0200 Subject: [PATCH] Split Matrix and Element into their own Compose stacks --- roles/docker/defaults/main.yml | 7 ++-- roles/docker/tasks/services/element.yml | 32 +++++++++++++++++++ .../{matrix_element.yml => matrix.yml} | 31 ++---------------- .../templates/compose-files/element.yml.j2 | 22 +++++++++++++ .../{matrix_element.yml.j2 => matrix.yml.j2} | 16 ---------- 5 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 roles/docker/tasks/services/element.yml rename roles/docker/tasks/services/{matrix_element.yml => matrix.yml} (56%) create mode 100644 roles/docker/templates/compose-files/element.yml.j2 rename roles/docker/templates/compose-files/{matrix_element.yml.j2 => matrix.yml.j2} (64%) diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 5477414..46cca1b 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -92,7 +92,7 @@ services: allowed_sender_domain: true matrix: - file: matrix_element.yml + file: matrix.yml domain: "matrix.{{ base_domain }}" volume_folder: "{{ volume_root_folder }}/matrix" version: v1.90.0 @@ -100,9 +100,8 @@ services: allowed_sender_domain: true element: - domains: - - "riot.{{ base_domain }}" - - "element.{{ base_domain }}" + file: element.yml + domain: "element.{{ base_domain }}" volume_folder: "{{ volume_root_folder }}/element" version: v1.11.43 diff --git a/roles/docker/tasks/services/element.yml b/roles/docker/tasks/services/element.yml new file mode 100644 index 0000000..b325bdf --- /dev/null +++ b/roles/docker/tasks/services/element.yml @@ -0,0 +1,32 @@ +# vim: ft=yaml.ansible +--- +- name: Create Element volume folder + file: + name: "{{ services.element.volume_folder }}/data" + state: directory + +- name: Upload Element config.json + template: + src: element/config.json.j2 + dest: "{{ services.element.volume_folder }}/data/config.json" + +- name: Upload Element riot.im.conf + copy: + src: element/riot.im.conf + dest: "{{ services.element.volume_folder }}/data/riot.im.conf" + +- name: Upload vhost config for Element domain + copy: + src: vhost/element + dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.element.domain }}" + +- name: Upload Compose file for Element + template: + src: compose-files/element.yml.j2 + dest: "{{ services.element.volume_folder }}/docker-compose.yml" + +- name: Deploy Element + docker_compose: + project_src: "{{ services.element.volume_folder }}" + pull: true + state: present diff --git a/roles/docker/tasks/services/matrix_element.yml b/roles/docker/tasks/services/matrix.yml similarity index 56% rename from roles/docker/tasks/services/matrix_element.yml rename to roles/docker/tasks/services/matrix.yml index 605084b..2a4a6f8 100644 --- a/roles/docker/tasks/services/matrix_element.yml +++ b/roles/docker/tasks/services/matrix.yml @@ -16,38 +16,13 @@ - name: Create Matrix DB folder file: name: "{{ services.matrix.volume_folder }}/db" - state: "directory" - -- name: Create Element volume folders - file: - name: "{{ services.element.volume_folder }}/{{ volume }}" state: directory - loop: - - "data" - loop_control: - loop_var: volume - -- name: Upload Element config.json - template: - src: element/config.json.j2 - dest: "{{ services.element.volume_folder }}/data/config.json" - -- name: Upload Element riot.im.conf - copy: - src: element/riot.im.conf - dest: "{{ services.element.volume_folder }}/data/riot.im.conf" - name: upload vhost config for matrix domain copy: src: vhost/matrix dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.matrix.domain }}" -- name: Upload vhost config for Element domain - copy: - src: vhost/element - dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ item }}" - loop: "{{ services.element.domains }}" - - name: Upload homeserver.yaml template: src: matrix/homeserver.yaml.j2 @@ -58,12 +33,12 @@ src: matrix/log.config dest: "{{ services.matrix.volume_folder }}/data/matrix.data.coop.log.config" -- name: Upload Compose file for Matrix and Element +- name: Upload Compose file for Matrix template: - src: compose-files/matrix_element.yml.j2 + src: compose-files/matrix.yml.j2 dest: "{{ services.matrix.volume_folder }}/docker-compose.yml" -- name: Deploy Matrix and Element +- name: Deploy Matrix docker_compose: project_src: "{{ services.matrix.volume_folder }}" pull: true diff --git a/roles/docker/templates/compose-files/element.yml.j2 b/roles/docker/templates/compose-files/element.yml.j2 new file mode 100644 index 0000000..2a875ce --- /dev/null +++ b/roles/docker/templates/compose-files/element.yml.j2 @@ -0,0 +1,22 @@ +# vim: ft=yaml.docker-compose +version: "3.8" + +services: + element: + image: avhost/docker-matrix-element:{{ services.element.version }} + restart: unless-stopped + networks: + - external_services + expose: + - "8080" + volumes: + - "./data:/data" + environment: + VIRTUAL_HOST: "{{ services.element.domain }}" + VIRTUAL_PORT: "8080" + LETSENCRYPT_HOST: "{{ services.element.domain }}" + LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" + +networks: + external_services: + external: true diff --git a/roles/docker/templates/compose-files/matrix_element.yml.j2 b/roles/docker/templates/compose-files/matrix.yml.j2 similarity index 64% rename from roles/docker/templates/compose-files/matrix_element.yml.j2 rename to roles/docker/templates/compose-files/matrix.yml.j2 index f787e61..0bbffa5 100644 --- a/roles/docker/templates/compose-files/matrix_element.yml.j2 +++ b/roles/docker/templates/compose-files/matrix.yml.j2 @@ -29,22 +29,6 @@ services: LETSENCRYPT_HOST: "{{ services.matrix.domain }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" - element: - image: avhost/docker-matrix-element:{{ services.element.version }} - restart: unless-stopped - networks: - - default - - external_services - expose: - - "8080" - volumes: - - "{{ services.element.volume_folder }}/data:/data" - environment: - VIRTUAL_HOST: "{{ services.element.domains | join(',') }}" - VIRTUAL_PORT: "8080" - LETSENCRYPT_HOST: "{{ services.element.domains | join(',') }}" - LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" - networks: external_services: external: true