2019-12-31 20:35:37 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure ma1sd paths exist
|
|
|
|
file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0750
|
|
|
|
owner: "{{ matrix_user_username }}"
|
2020-05-01 17:59:32 +00:00
|
|
|
group: "{{ matrix_user_groupname }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
with_items:
|
|
|
|
- { path: "{{ matrix_ma1sd_config_path }}", when: true }
|
|
|
|
- { path: "{{ matrix_ma1sd_data_path }}", when: true }
|
|
|
|
- { path: "{{ matrix_ma1sd_docker_src_files_path }}", when: "{{ matrix_ma1sd_container_image_self_build }}"}
|
2020-12-14 14:57:51 +00:00
|
|
|
when: "item.when|bool"
|
2019-12-31 20:35:37 +00:00
|
|
|
|
2020-04-03 10:12:03 +00:00
|
|
|
- import_tasks: "{{ role_path }}/tasks/migrate_mxisd.yml"
|
|
|
|
|
2020-12-14 15:16:25 +00:00
|
|
|
|
|
|
|
# These (SQLite -> Postgres) migration tasks are usually at the top,
|
|
|
|
# but we'd like to run them after `migrate_mxisd.yml`, which requires the ma1sd paths to exist.
|
|
|
|
- set_fact:
|
|
|
|
matrix_ma1sd_requires_restart: false
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Check if an SQLite database already exists
|
|
|
|
stat:
|
|
|
|
path: "{{ matrix_ma1sd_sqlite_database_path_local }}"
|
|
|
|
register: matrix_ma1sd_sqlite_database_path_local_stat_result
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- set_fact:
|
|
|
|
matrix_postgres_db_migration_request:
|
|
|
|
src: "{{ matrix_ma1sd_sqlite_database_path_local }}"
|
|
|
|
dst: "{{ matrix_ma1sd_database_connection_string }}"
|
|
|
|
caller: "{{ role_path|basename }}"
|
|
|
|
engine_variable_name: 'matrix_ma1sd_database_engine'
|
|
|
|
engine_old: 'sqlite'
|
|
|
|
systemd_services_to_stop: ['matrix-ma1sd.service']
|
|
|
|
pgloader_options: ['--with "quote identifiers"']
|
|
|
|
|
2020-12-23 10:38:47 +00:00
|
|
|
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
|
2020-12-14 15:16:25 +00:00
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
matrix_ma1sd_requires_restart: true
|
|
|
|
when: "matrix_ma1sd_sqlite_database_path_local_stat_result.stat.exists|bool"
|
|
|
|
when: "matrix_ma1sd_database_engine == 'postgres'"
|
|
|
|
|
2019-12-31 20:35:37 +00:00
|
|
|
- name: Ensure ma1sd image is pulled
|
|
|
|
docker_image:
|
|
|
|
name: "{{ matrix_ma1sd_docker_image }}"
|
|
|
|
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
|
|
|
force_source: "{{ matrix_ma1sd_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_ma1sd_docker_image_force_pull }}"
|
2020-12-14 14:57:51 +00:00
|
|
|
when: "not matrix_ma1sd_container_image_self_build|bool"
|
2019-12-31 20:35:37 +00:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Ensure gradle is installed for self-building (Debian)
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- gradle
|
|
|
|
state: present
|
|
|
|
update_cache: yes
|
|
|
|
when: (ansible_os_family == 'Debian')
|
|
|
|
|
|
|
|
- name: Ensure gradle is installed for self-building (CentOS)
|
|
|
|
fail:
|
|
|
|
msg: "Installing gradle on CentOS is currently not supported, so self-building ma1sd cannot happen at this time"
|
|
|
|
when: ansible_distribution == 'CentOS'
|
|
|
|
|
|
|
|
- name: Ensure gradle is installed for self-building (Archlinux)
|
|
|
|
pacman:
|
|
|
|
name:
|
|
|
|
- gradle
|
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_distribution == 'Archlinux'
|
|
|
|
|
|
|
|
- name: Ensure ma1sd repository is present on self-build
|
|
|
|
git:
|
2020-11-28 19:34:14 +00:00
|
|
|
repo: "{{ matrix_ma1sd_container_image_self_build_repo }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
dest: "{{ matrix_ma1sd_docker_src_files_path }}"
|
2021-01-14 21:57:38 +00:00
|
|
|
version: "{{ matrix_ma1sd_container_image_self_build_branch }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
force: "yes"
|
2020-11-14 20:47:14 +00:00
|
|
|
register: matrix_ma1sd_git_pull_results
|
2019-12-31 20:35:37 +00:00
|
|
|
|
|
|
|
- name: Ensure ma1sd Docker image is built
|
2021-01-14 21:48:30 +00:00
|
|
|
shell: "DOCKER_BUILDKIT=1 ./gradlew dockerBuild"
|
2019-12-31 20:35:37 +00:00
|
|
|
args:
|
|
|
|
chdir: "{{ matrix_ma1sd_docker_src_files_path }}"
|
2020-07-17 07:12:16 +00:00
|
|
|
|
|
|
|
- name: Ensure ma1sd Docker image is tagged correctly
|
|
|
|
docker_image:
|
2021-01-14 21:57:38 +00:00
|
|
|
# The build script always tags the image with 2 tags:
|
|
|
|
# - based on the branch/version: e.g. `ma1uta/ma1sd:2.4.0` (when on `2.4.0`)
|
|
|
|
# or `ma1uta/ma1sd:2.4.0-19-ga71d32b` (when on a given commit for a pre-release)
|
|
|
|
# - generic one: `ma1uta/ma1sd:latest-dev`
|
|
|
|
#
|
|
|
|
# It's hard to predict the first one, so we'll use the latter.
|
|
|
|
name: "ma1uta/ma1sd:latest-dev"
|
2020-07-17 07:12:16 +00:00
|
|
|
repository: "{{ matrix_ma1sd_docker_image }}"
|
|
|
|
force_tag: yes
|
|
|
|
source: local
|
2020-12-14 14:57:51 +00:00
|
|
|
when: "matrix_ma1sd_container_image_self_build|bool"
|
2019-12-31 20:35:37 +00:00
|
|
|
|
|
|
|
- name: Ensure ma1sd config installed
|
|
|
|
copy:
|
|
|
|
content: "{{ matrix_ma1sd_configuration|to_nice_yaml }}"
|
|
|
|
dest: "{{ matrix_ma1sd_config_path }}/ma1sd.yaml"
|
|
|
|
mode: 0644
|
|
|
|
owner: "{{ matrix_user_username }}"
|
2020-05-01 17:59:32 +00:00
|
|
|
group: "{{ matrix_user_groupname }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
|
2021-01-03 05:36:09 +00:00
|
|
|
- name: Ensure custom view templates are installed, if any
|
|
|
|
copy:
|
|
|
|
content: "{{ item.value }}"
|
|
|
|
dest: "{{ matrix_ma1sd_config_path }}/{{ item.location }}"
|
|
|
|
mode: 0644
|
|
|
|
owner: "{{ matrix_user_username }}"
|
|
|
|
group: "{{ matrix_user_groupname }}"
|
|
|
|
with_items:
|
|
|
|
- {value: "{{ matrix_ma1sd_view_session_custom_onTokenSubmit_success_template }}", location: 'tokenSubmitSuccess.html'}
|
|
|
|
- {value: "{{ matrix_ma1sd_view_session_custom_onTokenSubmit_failure_template }}", location: 'tokenSubmitFailure.html'}
|
|
|
|
when: "matrix_ma1sd_view_session_custom_templates_enabled|bool and item.value"
|
|
|
|
|
2021-01-03 05:35:13 +00:00
|
|
|
- name: Ensure custom email templates are installed, if any
|
2019-12-31 20:35:37 +00:00
|
|
|
copy:
|
|
|
|
content: "{{ item.value }}"
|
2021-01-03 05:35:13 +00:00
|
|
|
dest: "{{ matrix_ma1sd_config_path }}/{{ item.location }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
mode: 0644
|
|
|
|
owner: "{{ matrix_user_username }}"
|
2020-05-01 17:59:32 +00:00
|
|
|
group: "{{ matrix_user_groupname }}"
|
2019-12-31 20:35:37 +00:00
|
|
|
with_items:
|
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_invite_template }}", location: 'invite-template.eml'}
|
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_validation_template }}", location: 'validate-template.eml'}
|
2021-01-03 05:35:13 +00:00
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_unbind_notification_template }}", location: 'unbind-notification.eml'}
|
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_matrixid_template }}", location: 'mxid-template.eml'}
|
|
|
|
when: "matrix_ma1sd_threepid_medium_email_custom_templates_enabled|bool and item.value"
|
|
|
|
|
|
|
|
# Only cleaning up for people who define the respective templates
|
|
|
|
- name: (Cleanup) Ensure custom email templates are not in data/ anymore (we've put them in config/)
|
|
|
|
file:
|
|
|
|
path: "{{ matrix_ma1sd_data_path }}/{{ item.location }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_invite_template }}", location: 'invite-template.eml'}
|
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_validation_template }}", location: 'validate-template.eml'}
|
2021-01-02 22:58:09 +00:00
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_unbind_notification_template }}", location: 'unbind-notification.eml'}
|
2019-12-31 20:35:37 +00:00
|
|
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_matrixid_template }}", location: 'mxid-template.eml'}
|
2020-12-14 14:57:51 +00:00
|
|
|
when: "matrix_ma1sd_threepid_medium_email_custom_templates_enabled|bool and item.value"
|
2019-12-31 20:35:37 +00:00
|
|
|
|
|
|
|
- name: Ensure matrix-ma1sd.service installed
|
|
|
|
template:
|
|
|
|
src: "{{ role_path }}/templates/systemd/matrix-ma1sd.service.j2"
|
|
|
|
dest: "{{ matrix_systemd_path }}/matrix-ma1sd.service"
|
|
|
|
mode: 0644
|
|
|
|
register: matrix_ma1sd_systemd_service_result
|
|
|
|
|
|
|
|
- name: Ensure systemd reloaded after matrix-ma1sd.service installation
|
|
|
|
service:
|
|
|
|
daemon_reload: yes
|
2020-12-14 14:57:51 +00:00
|
|
|
when: "matrix_ma1sd_systemd_service_result.changed|bool"
|
2020-12-14 15:16:25 +00:00
|
|
|
|
|
|
|
- name: Ensure matrix-ma1sd.service restarted, if necessary
|
|
|
|
service:
|
|
|
|
name: "matrix-ma1sd.service"
|
|
|
|
state: restarted
|
|
|
|
when: "matrix_ma1sd_requires_restart|bool"
|