You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
7.8 KiB
179 lines
7.8 KiB
5 years ago
|
---
|
||
|
|
||
|
- name: Ensure ma1sd paths exist
|
||
2 years ago
|
ansible.builtin.file:
|
||
5 years ago
|
path: "{{ item.path }}"
|
||
|
state: directory
|
||
|
mode: 0750
|
||
|
owner: "{{ matrix_user_username }}"
|
||
5 years ago
|
group: "{{ matrix_user_groupname }}"
|
||
5 years ago
|
with_items:
|
||
3 years ago
|
- {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 }}"}
|
||
2 years ago
|
when: "item.when | bool"
|
||
5 years ago
|
|
||
2 years ago
|
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/migrate_mxisd.yml"
|
||
5 years ago
|
|
||
4 years ago
|
|
||
|
# 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.
|
||
2 years ago
|
- ansible.builtin.set_fact:
|
||
4 years ago
|
matrix_ma1sd_requires_restart: false
|
||
|
|
||
2 years ago
|
- when: "matrix_ma1sd_database_engine == 'postgres'"
|
||
|
block:
|
||
4 years ago
|
- name: Check if an SQLite database already exists
|
||
2 years ago
|
ansible.builtin.stat:
|
||
4 years ago
|
path: "{{ matrix_ma1sd_sqlite_database_path_local }}"
|
||
|
register: matrix_ma1sd_sqlite_database_path_local_stat_result
|
||
|
|
||
2 years ago
|
- when: "matrix_ma1sd_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||
|
block:
|
||
2 years ago
|
- ansible.builtin.set_fact:
|
||
4 years ago
|
matrix_postgres_db_migration_request:
|
||
|
src: "{{ matrix_ma1sd_sqlite_database_path_local }}"
|
||
|
dst: "{{ matrix_ma1sd_database_connection_string }}"
|
||
2 years ago
|
caller: "{{ role_path | basename }}"
|
||
4 years ago
|
engine_variable_name: 'matrix_ma1sd_database_engine'
|
||
|
engine_old: 'sqlite'
|
||
|
systemd_services_to_stop: ['matrix-ma1sd.service']
|
||
|
pgloader_options: ['--with "quote identifiers"']
|
||
|
|
||
2 years ago
|
- ansible.builtin.import_role:
|
||
2 years ago
|
name: custom/matrix-postgres
|
||
2 years ago
|
tasks_from: migrate_db_to_postgres
|
||
4 years ago
|
|
||
2 years ago
|
- ansible.builtin.set_fact:
|
||
4 years ago
|
matrix_ma1sd_requires_restart: true
|
||
|
|
||
5 years ago
|
- name: Ensure ma1sd image is pulled
|
||
2 years ago
|
community.docker.docker_image:
|
||
5 years ago
|
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 }}"
|
||
2 years ago
|
when: "not matrix_ma1sd_container_image_self_build | bool"
|
||
3 years ago
|
register: result
|
||
|
retries: "{{ matrix_container_retries_count }}"
|
||
|
delay: "{{ matrix_container_retries_delay }}"
|
||
|
until: result is not failed
|
||
5 years ago
|
|
||
2 years ago
|
- when: "matrix_ma1sd_container_image_self_build | bool"
|
||
|
block:
|
||
3 years ago
|
- name: Ensure gradle is installed for self-building (Debian)
|
||
2 years ago
|
ansible.builtin.apt:
|
||
3 years ago
|
name:
|
||
|
- gradle
|
||
|
state: present
|
||
|
update_cache: true
|
||
|
when: (ansible_os_family == 'Debian')
|
||
|
|
||
3 years ago
|
- name: Ensure gradle is installed for self-building (RedHat)
|
||
2 years ago
|
ansible.builtin.fail:
|
||
3 years ago
|
msg: "Installing gradle on RedHat ({{ ansible_distribution }}) is currently not supported, so self-building ma1sd cannot happen at this time"
|
||
|
when: ansible_os_family == 'RedHat'
|
||
3 years ago
|
|
||
|
- name: Ensure gradle is installed for self-building (Archlinux)
|
||
2 years ago
|
community.general.pacman:
|
||
3 years ago
|
name:
|
||
|
- gradle
|
||
2 years ago
|
state: present
|
||
3 years ago
|
update_cache: true
|
||
|
when: ansible_distribution == 'Archlinux'
|
||
|
|
||
|
- name: Ensure ma1sd repository is present on self-build
|
||
2 years ago
|
ansible.builtin.git:
|
||
3 years ago
|
repo: "{{ matrix_ma1sd_container_image_self_build_repo }}"
|
||
|
dest: "{{ matrix_ma1sd_docker_src_files_path }}"
|
||
|
version: "{{ matrix_ma1sd_container_image_self_build_branch }}"
|
||
|
force: "yes"
|
||
3 years ago
|
become: true
|
||
|
become_user: "{{ matrix_user_username }}"
|
||
3 years ago
|
register: matrix_ma1sd_git_pull_results
|
||
|
|
||
|
- name: Ensure ma1sd Docker image is built
|
||
2 years ago
|
ansible.builtin.command:
|
||
|
cmd: ./gradlew dockerBuild
|
||
3 years ago
|
chdir: "{{ matrix_ma1sd_docker_src_files_path }}"
|
||
2 years ago
|
environment:
|
||
|
DOCKER_BUILDKIT: 1
|
||
3 years ago
|
when: matrix_ma1sd_git_pull_results.changed
|
||
3 years ago
|
|
||
|
- name: Ensure ma1sd Docker image is tagged correctly
|
||
2 years ago
|
community.docker.docker_image:
|
||
3 years ago
|
# 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"
|
||
|
repository: "{{ matrix_ma1sd_docker_image }}"
|
||
|
force_tag: true
|
||
|
source: local
|
||
5 years ago
|
|
||
|
- name: Ensure ma1sd config installed
|
||
2 years ago
|
ansible.builtin.copy:
|
||
2 years ago
|
content: "{{ matrix_ma1sd_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||
5 years ago
|
dest: "{{ matrix_ma1sd_config_path }}/ma1sd.yaml"
|
||
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
5 years ago
|
group: "{{ matrix_user_groupname }}"
|
||
5 years ago
|
|
||
4 years ago
|
- name: Ensure custom view templates are installed, if any
|
||
2 years ago
|
ansible.builtin.copy:
|
||
4 years ago
|
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'}
|
||
2 years ago
|
when: "matrix_ma1sd_view_session_custom_templates_enabled | bool and item.value"
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure custom email templates are installed, if any
|
||
2 years ago
|
ansible.builtin.copy:
|
||
5 years ago
|
content: "{{ item.value }}"
|
||
4 years ago
|
dest: "{{ matrix_ma1sd_config_path }}/{{ item.location }}"
|
||
5 years ago
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
5 years ago
|
group: "{{ matrix_user_groupname }}"
|
||
5 years ago
|
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'}
|
||
4 years ago
|
- {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'}
|
||
2 years ago
|
when: "matrix_ma1sd_threepid_medium_email_custom_templates_enabled | bool and item.value"
|
||
4 years ago
|
|
||
|
# 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/)
|
||
2 years ago
|
ansible.builtin.file:
|
||
4 years ago
|
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'}
|
||
4 years ago
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_session_unbind_notification_template }}", location: 'unbind-notification.eml'}
|
||
5 years ago
|
- {value: "{{ matrix_ma1sd_threepid_medium_email_custom_matrixid_template }}", location: 'mxid-template.eml'}
|
||
2 years ago
|
when: "matrix_ma1sd_threepid_medium_email_custom_templates_enabled | bool and item.value"
|
||
5 years ago
|
|
||
|
- name: Ensure matrix-ma1sd.service installed
|
||
2 years ago
|
ansible.builtin.template:
|
||
5 years ago
|
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
|
||
2 years ago
|
ansible.builtin.service:
|
||
3 years ago
|
daemon_reload: true
|
||
2 years ago
|
when: "matrix_ma1sd_systemd_service_result.changed | bool"
|
||
4 years ago
|
|
||
|
- name: Ensure matrix-ma1sd.service restarted, if necessary
|
||
2 years ago
|
ansible.builtin.service:
|
||
4 years ago
|
name: "matrix-ma1sd.service"
|
||
|
state: restarted
|
||
2 years ago
|
when: "matrix_ma1sd_requires_restart | bool"
|