refactor based on Slavi's requests

This commit is contained in:
Horvath Gergely 2020-03-08 00:24:00 +01:00
parent d53d63ab07
commit 310aa685f9
17 changed files with 96 additions and 101 deletions

View File

@ -678,19 +678,3 @@ matrix_synapse_systemd_wanted_services_list: |
# /matrix-synapse
#
######################################################################
######################################################################
#
# raspberry pi
#
######################################################################
matrix_raspberry_pi: "false"
######################################################################
#
# /raspberry pi
#
######################################################################

View File

@ -26,13 +26,6 @@ matrix_base_data_path: "/matrix"
matrix_base_data_path_mode: "750"
matrix_static_files_base_path: "{{ matrix_base_data_path }}/static-files"
matrix_docker_src_files_path: "{{ matrix_base_data_path }}/docker-src"
matrix_docker_synapse_src_files_path: "{{ matrix_docker_src_files_path }}/synapse"
matrix_docker_riot_web_src_files_path: "{{ matrix_docker_src_files_path }}/riot-web"
matrix_docker_coturn_src_files_path: "{{ matrix_docker_src_files_path }}/coturn"
matrix_docker_mxisd_src_files_path: "{{ matrix_docker_src_files_path }}/mxisd"
matrix_docker_mautrix_facebook_src_files_path: "{{ matrix_docker_src_files_path }}/mautrix-facebook"
matrix_docker_mautrix_hangouts_src_files_path: "{{ matrix_docker_src_files_path }}/mautrix-hangouts"
matrix_homeserver_url: "https://{{ matrix_server_fqn_matrix }}"
@ -73,3 +66,6 @@ run_setup: true
run_self_check: true
run_start: true
run_stop: true
# Raspberry pi depoly TODO: it should be identified based on the operating system
matrix_raspberry_pi_deploy: false

View File

@ -7,7 +7,7 @@
when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian')
- include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml"
when: "matrix_raspberry_pi"
when: "matrix_raspberry_pi_deploy"
- name: Ensure Docker is started and autoruns
service:

View File

@ -22,13 +22,6 @@
group: "{{ matrix_user_username }}"
with_items:
- "{{ matrix_base_data_path }}"
- { src: "{{ matrix_docker_src_files_path }}", when: "{{ matrix_raspberry_pi }}" }
- { src: "{{ matrix_docker_synapse_src_files_path }}", when: "{{ matrix_raspberry_pi }}" }
- { src: "{{ matrix_docker_riot_web_src_files_path }}", when: "{{ matrix_raspberry_pi }}" }
- { src: "{{ matrix_docker_coturn_src_files_path }}", when: "{{ matrix_coturn_enabled }}"}
- { src: "{{ matrix_docker_mxisd_src_files_path }}", when: "{{ matrix_mxisd_enabled }}"}
- { src: "{{ matrix_docker_mautrix_facebook_src_files_path }}", when: "{{ matrix_mautrix_facebook_enabled }}"}
- { src: "{{ matrix_docker_mautrix_hangouts_src_files_path }}", when: "{{ matrix_mautrix_hangouts_enabled }}"}
# `docker_network` doesn't work as expected when the given network
# is a substring of a network that already exists.

View File

@ -2,6 +2,7 @@
# See: https://github.com/tulir/mautrix-facebook
matrix_mautrix_facebook_enabled: true
matrix_mautrix_facebook_self_build: false
# See: https://mau.dev/tulir/mautrix-facebook/container_registry
matrix_mautrix_facebook_docker_image: "dock.mau.dev/tulir/mautrix-facebook:latest"
@ -10,6 +11,7 @@ matrix_mautrix_facebook_docker_image_force_pull: "{{ matrix_mautrix_facebook_doc
matrix_mautrix_facebook_base_path: "{{ matrix_base_data_path }}/mautrix-facebook"
matrix_mautrix_facebook_config_path: "{{ matrix_mautrix_facebook_base_path }}/config"
matrix_mautrix_facebook_data_path: "{{ matrix_mautrix_facebook_base_path }}/data"
matrix_docker_mautrix_facebook_src_files_path: "{{ matrix_mautrix_facebook_base_path }}/docker-src"
matrix_mautrix_facebook_homeserver_address: 'http://matrix-synapse:8008'
matrix_mautrix_facebook_homeserver_domain: '{{ matrix_domain }}'

View File

@ -14,25 +14,7 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_mautrix_facebook_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_facebook_docker_image_force_pull }}"
when: matrix_mautrix_facebook_enabled|bool and not matrix_raspberry_pi
- name: Ensure Mautrix Facebook repository is present on Raspberry pi
git:
repo: https://github.com/tulir/mautrix-facebook.git
dest: "{{ matrix_docker_mautrix_facebook_src_files_path }}"
# version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_mautrix_facebook_enabled|bool and matrix_raspberry_pi"
- name: Ensure Mautrix Facebook Docker image is build (Raspberry pi)
docker_image:
name: "{{ matrix_mautrix_facebook_docker_image }}"
source: build
build:
dockerfile: Dockerfile
path: "{{ matrix_docker_mautrix_facebook_src_files_path }}"
pull: yes
when: "matrix_mautrix_facebook_enabled|bool and matrix_raspberry_pi"
when: matrix_mautrix_facebook_enabled|bool and not matrix_mautrix_facebook_self_build
- name: Ensure Mautrix Facebook paths exist
file:
@ -45,6 +27,25 @@
- "{{ matrix_mautrix_facebook_base_path }}"
- "{{ matrix_mautrix_facebook_config_path }}"
- "{{ matrix_mautrix_facebook_data_path }}"
- { src: "{{ matrix_docker_mautrix_facebook_src_files_path }}", when: "{{ matrix_mautrix_facebook_self_build }}" }
- name: Ensure Mautrix Facebook repository is present on self-build
git:
repo: https://github.com/tulir/mautrix-facebook.git
dest: "{{ matrix_docker_mautrix_facebook_src_files_path }}"
# version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_mautrix_facebook_enabled|bool and matrix_mautrix_facebook_self_build"
- name: Ensure Mautrix Facebook Docker image is build
docker_image:
name: "{{ matrix_mautrix_facebook_docker_image }}"
source: build
build:
dockerfile: Dockerfile
path: "{{ matrix_docker_mautrix_facebook_src_files_path }}"
pull: yes
when: "matrix_mautrix_facebook_enabled|bool and matrix_mautrix_facebook_self_build"
- name: Check if an old database file already exists
stat:

View File

@ -2,6 +2,7 @@
# See: https://github.com/tulir/mautrix-hangouts
matrix_mautrix_hangouts_enabled: true
matrix_mautrix_hangouts_self_build: true
# See: https://mau.dev/tulir/mautrix-hangouts/container_registry
matrix_mautrix_hangouts_docker_image: "dock.mau.dev/tulir/mautrix-hangouts:latest"
@ -10,6 +11,7 @@ matrix_mautrix_hangouts_docker_image_force_pull: "{{ matrix_mautrix_hangouts_doc
matrix_mautrix_hangouts_base_path: "{{ matrix_base_data_path }}/mautrix-hangouts"
matrix_mautrix_hangouts_config_path: "{{ matrix_mautrix_hangouts_base_path }}/config"
matrix_mautrix_hangouts_data_path: "{{ matrix_mautrix_hangouts_base_path }}/data"
matrix_docker_mautrix_hangouts_src_files_path: "{{ matrix_mautrix_hangouts_base_path }}/docker-src"
matrix_mautrix_hangouts_public_endpoint: '/mautrix-hangouts'

View File

@ -14,24 +14,7 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_mautrix_hangouts_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_hangouts_docker_image_force_pull }}"
when: matrix_mautrix_hangouts_enabled|bool and not matrix_raspberry_pi
- name: Ensure Mautrix Hangots repository is present on Raspberry pi
git:
repo: https://github.com/tulir/mautrix-hangouts.git
dest: "{{ matrix_docker_mautrix_hangouts_src_files_path }}"
force: "yes"
when: "matrix_mautrix_hangouts_enabled|bool and matrix_raspberry_pi"
- name: Ensure Mautrix Hangouts Docker image is build (Raspberry pi)
docker_image:
name: "{{ matrix_mautrix_hangouts_docker_image }}"
source: build
build:
dockerfile: Dockerfile
path: "{{ matrix_docker_mautrix_hangouts_src_files_path }}"
pull: yes
when: "matrix_mautrix_hangouts_enabled|bool and matrix_raspberry_pi"
when: matrix_mautrix_hangouts_enabled|bool and not matrix_mautrix_hangouts_self_build
- name: Ensure Mautrix Hangouts paths exist
file:
@ -44,6 +27,26 @@
- "{{ matrix_mautrix_hangouts_base_path }}"
- "{{ matrix_mautrix_hangouts_config_path }}"
- "{{ matrix_mautrix_hangouts_data_path }}"
- { src: "{{ matrix_docker_mautrix_hangouts_src_files_path }}", when: "{{ matrix_mautrix_hangouts_self_build }}" }
when: matrix_mautrix_hangouts_enabled|bool and not matrix_mautrix_hangouts_self_build
- name: Ensure Mautrix Hangots repository is present on self build
git:
repo: https://github.com/tulir/mautrix-hangouts.git
dest: "{{ matrix_docker_mautrix_hangouts_src_files_path }}"
force: "yes"
when: "matrix_mautrix_hangouts_enabled|bool and matrix_mautrix_hangouts_self_build"
- name: Ensure Mautrix Hangouts Docker image is build
docker_image:
name: "{{ matrix_mautrix_hangouts_docker_image }}"
source: build
build:
dockerfile: Dockerfile
path: "{{ matrix_docker_mautrix_hangouts_src_files_path }}"
pull: yes
when: "matrix_mautrix_hangouts_enabled|bool and matrix_mautrix_hangouts_self_build"
- name: Check if an old database file already exists
stat:

View File

@ -1,4 +1,5 @@
matrix_coturn_enabled: true
matrix_coturn_self_build: false
matrix_coturn_docker_image: "instrumentisto/coturn:4.5.1.1"
matrix_coturn_docker_image_force_pull: "{{ matrix_coturn_docker_image.endswith(':latest') }}"
@ -13,6 +14,7 @@ matrix_coturn_docker_image_force_pull: "{{ matrix_coturn_docker_image.endswith('
matrix_coturn_docker_network: "matrix-coturn"
matrix_coturn_base_path: "{{ matrix_base_data_path }}/coturn"
matrix_docker_coturn_src_files_path: "{{ matrix_coturn_base_path }}/docker-src"
matrix_coturn_config_path: "{{ matrix_coturn_base_path }}/turnserver.conf"
# List of systemd services that matrix-coturn.service depends on

View File

@ -4,23 +4,34 @@
# Tasks related to setting up Coturn
#
- name: Ensure Matrix Coturn path exists
file:
path: "{{ item }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_username }}"
with_items:
- { src: "{{ matrix_docker_coturn_src_files_path }}", when: "{{ matrix_coturn_self_build }}"}
when: matrix_riot_web_enabled|bool
- name: Ensure Coturn image is pulled
docker_image:
name: "{{ matrix_coturn_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_coturn_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_docker_image_force_pull }}"
when: matrix_coturn_enabled|bool and not matrix_raspberry_pi
when: matrix_coturn_enabled|bool and not matrix_coturn_self_build
- name: Ensure Coturn repository is present on Raspberry pi
- name: Ensure Coturn repository is present on self-build
git:
repo: https://github.com/instrumentisto/coturn-docker-image.git
dest: "{{ matrix_docker_coturn_src_files_path }}"
version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_coturn_enabled|bool and matrix_raspberry_pi"
when: "matrix_coturn_enabled|bool and matrix_coturn_self_build"
- name: Ensure Coturn Docker image is build (Raspberry pi)
- name: Ensure Coturn Docker image is build
docker_image:
name: "{{ matrix_coturn_docker_image }}"
source: build
@ -28,7 +39,7 @@
dockerfile: Dockerfile
path: "{{ matrix_docker_coturn_src_files_path }}"
pull: yes
when: "matrix_coturn_enabled|bool and matrix_raspberry_pi"
when: "matrix_coturn_enabled|bool and matrix_coturn_self_build"
- name: Ensure Coturn configuration path exists
file:

View File

@ -2,11 +2,13 @@
# See: https://github.com/kamax-matrix/mxisd
matrix_mxisd_enabled: true
matrix_mxisd_self_build: false
matrix_mxisd_docker_image: "kamax/mxisd:1.4.6"
matrix_mxisd_docker_image_force_pull: "{{ matrix_mxisd_docker_image.endswith(':latest') }}"
matrix_mxisd_base_path: "{{ matrix_base_data_path }}/mxisd"
matrix_docker_mxisd_src_files_path: "{{ matrix_mxisd_base_path }}/docker-src"
matrix_mxisd_config_path: "{{ matrix_mxisd_base_path }}/config"
matrix_mxisd_data_path: "{{ matrix_mxisd_base_path }}/data"

View File

@ -14,6 +14,7 @@
with_items:
- "{{ matrix_mxisd_config_path }}"
- "{{ matrix_mxisd_data_path }}"
- { src: "{{ matrix_docker_mxisd_src_files_path }}", when: "{{ matrix_mxisd_self_build }}"}
when: matrix_mxisd_enabled|bool
- name: Ensure mxisd image is pulled
@ -22,39 +23,29 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_mxisd_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mxisd_docker_image_force_pull }}"
when: matrix_mxisd_enabled|bool and not matrix_raspberry_pi
when: matrix_mxisd_enabled|bool and not matrix_mxisd_self_build
- name: Ensure gradel is installed on Raspberry pi for building
- name: Ensure gradel is installed for self-building
apt:
name:
- gradle
state: present
update_cache: yes
when: "matrix_mxisd_enabled|bool and matrix_raspberry_pi"
when: "matrix_mxisd_enabled|bool and matrix_mxisd_self_build"
- name: Ensure mxisd repository is present on Raspberry pi
- name: Ensure mxisd repository is present on self-build
git:
repo: https://github.com/kamax-matrix/mxisd.git
dest: "{{ matrix_docker_mxisd_src_files_path }}"
version: "v{{ matrix_mxisd_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_mxisd_enabled|bool and matrix_raspberry_pi"
when: "matrix_mxisd_enabled|bool and matrix_mxisd_self_build"
# - name: Ensure mxisd Docker image is build (Raspberry pi)
# docker_image:
# name: "{{ matrix_mxisd_docker_image }}"
# source: build
# build:
# dockerfile: Dockerfile
# path: "{{ matrix_docker_mxisd_src_files_path }}"
# pull: yes
# when: "matrix_mxisd_enabled|bool and matrix_raspberry_pi"
- name: Ensure mxisd Docker image is build (Raspberry pi)
- name: Ensure mxisd Docker image is build
shell: "./gradlew dockerBuild"
args:
chdir: "{{ matrix_docker_mxisd_src_files_path }}"
when: "matrix_mxisd_enabled|bool and matrix_raspberry_pi"
when: "matrix_mxisd_enabled|bool and matrix_mxisd_self_build"
- name: Ensure mxisd config installed
copy:

View File

@ -1,9 +1,11 @@
matrix_riot_web_enabled: true
matrix_riot_web_self_build: false
matrix_riot_web_docker_image: "vectorim/riot-web:v1.5.12"
matrix_riot_web_docker_image_force_pull: "{{ matrix_riot_web_docker_image.endswith(':latest') }}"
matrix_riot_web_data_path: "{{ matrix_base_data_path }}/riot-web"
matrix_docker_riot_web_src_files_path: "{{ matrix_riot_web_data_path }}/docker-src"
# Controls whether the matrix-riot-web container exposes its HTTP port (tcp/8080 in the container).
#

View File

@ -6,11 +6,14 @@
- name: Ensure Matrix riot-web path exists
file:
path: "{{ matrix_riot_web_data_path }}"
path: "{{ item }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_username }}"
with_items:
- "{{ matrix_riot_web_data_path }}"
- { src: "{{ matrix_docker_riot_web_src_files_path }}", when: "{{ matrix_riot_web_self_build }}" }
when: matrix_riot_web_enabled|bool
- name: Ensure riot-web Docker image is pulled
@ -19,17 +22,17 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_riot_web_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_riot_web_docker_image_force_pull }}"
when: matrix_riot_web_enabled|bool and not matrix_raspberry_pi
when: matrix_riot_web_enabled|bool and not matrix_riot_web_self_build
- name: Ensure Riot Web repository is present on Raspberry pi
- name: Ensure Riot Web repository is present on self-build
git:
repo: https://github.com/vector-im/riot-web.git
dest: "{{ matrix_docker_riot_web_src_files_path }}"
version: "v{{ matrix_riot_web_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_riot_web_enabled|bool and matrix_raspberry_pi"
when: "matrix_riot_web_enabled|bool and matrix_riot_web_self_build"
- name: Ensure Riot Web Docker image is build (Raspberry pi)
- name: Ensure Riot Web Docker image is build
docker_image:
name: "{{ matrix_riot_web_docker_image }}"
source: build
@ -37,7 +40,7 @@
dockerfile: Dockerfile
path: "{{ matrix_docker_riot_web_src_files_path }}"
pull: yes
when: "matrix_riot_web_enabled|bool and matrix_raspberry_pi"
when: "matrix_riot_web_enabled|bool and matrix_self_build"
- name: Ensure Matrix riot-web configuration installed
copy:

View File

@ -2,11 +2,13 @@
# See: https://github.com/matrix-org/synapse
matrix_synapse_enabled: true
matrix_synapse_self_build: false
matrix_synapse_docker_image: "matrixdotorg/synapse:v1.11.1"
matrix_synapse_docker_image_force_pull: "{{ matrix_synapse_docker_image.endswith(':latest') }}"
matrix_synapse_base_path: "{{ matrix_base_data_path }}/synapse"
matrix_docker_synapse_src_files_path: "{{ matrix_synapse_base_path }}/docker-src"
matrix_synapse_config_dir_path: "{{ matrix_synapse_base_path }}/config"
matrix_synapse_run_path: "{{ matrix_synapse_base_path }}/run"
matrix_synapse_storage_path: "{{ matrix_synapse_base_path }}/storage"

View File

@ -11,6 +11,7 @@
- "{{ matrix_synapse_config_dir_path }}"
- "{{ matrix_synapse_run_path }}"
- "{{ matrix_synapse_ext_path }}"
- { src: "{{ matrix_docker_synapse_src_files_path }}", when: "{{ matrix_synapse_self_build }}" }
# We handle matrix_synapse_media_store_path elsewhere (in ./synapse/setup_install.yml),
# because if it's using Goofys and it's already mounted (from before),
# trying to chown/chmod it here will cause trouble.

View File

@ -18,15 +18,15 @@
group: "{{ matrix_user_username }}"
when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
- name: Ensure Synapse repository is present on Raspberry pi
- name: Ensure Synapse repository is present on self-build
git:
repo: https://github.com/matrix-org/synapse.git
dest: "{{ matrix_docker_synapse_src_files_path }}"
version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
force: "yes"
when: "matrix_raspberry_pi"
when: "matrix_synapse_self_build"
- name: Ensure Synapse Docker image is build (Raspberry pi)
- name: Ensure Synapse Docker image is build
docker_image:
name: "{{ matrix_synapse_docker_image }}"
source: build
@ -34,7 +34,7 @@
dockerfile: docker/Dockerfile
path: "{{ matrix_docker_synapse_src_files_path }}"
pull: yes
when: "matrix_raspberry_pi"
when: "matrix_synapse_self_build"
- name: Ensure Synapse Docker image is pulled
docker_image:
@ -42,7 +42,7 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_synapse_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_docker_image_force_pull }}"
when: "not matrix_raspberry_pi"
when: "not matrix_synapse_self_build"
- name: Check if a Synapse signing key exists
stat: