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.
139 lines
6.1 KiB
139 lines
6.1 KiB
5 years ago
|
---
|
||
|
|
||
|
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
|
||
|
# We don't want to fail in such cases.
|
||
|
- name: Fail if matrix-synapse role already executed
|
||
2 years ago
|
ansible.builtin.fail:
|
||
5 years ago
|
msg: >-
|
||
|
The matrix-bridge-mautrix-hangouts role needs to execute before the matrix-synapse role.
|
||
2 years ago
|
when: "matrix_synapse_role_executed | default(False)"
|
||
5 years ago
|
|
||
2 years ago
|
- ansible.builtin.set_fact:
|
||
4 years ago
|
matrix_mautrix_hangouts_requires_restart: false
|
||
|
|
||
2 years ago
|
- when: "matrix_mautrix_hangouts_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_mautrix_hangouts_sqlite_database_path_local }}"
|
||
|
register: matrix_mautrix_hangouts_sqlite_database_path_local_stat_result
|
||
|
|
||
2 years ago
|
- when: "matrix_mautrix_hangouts_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_mautrix_hangouts_sqlite_database_path_local }}"
|
||
|
dst: "{{ matrix_mautrix_hangouts_database_connection_string }}"
|
||
2 years ago
|
caller: "{{ role_path | basename }}"
|
||
4 years ago
|
engine_variable_name: 'matrix_mautrix_hangouts_database_engine'
|
||
|
engine_old: 'sqlite'
|
||
|
systemd_services_to_stop: ['matrix-mautrix-hangouts.service']
|
||
|
|
||
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_mautrix_hangouts_requires_restart: true
|
||
4 years ago
|
|
||
5 years ago
|
- name: Ensure Mautrix Hangouts image is pulled
|
||
2 years ago
|
community.docker.docker_image:
|
||
5 years ago
|
name: "{{ matrix_mautrix_hangouts_docker_image }}"
|
||
|
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 }}"
|
||
3 years ago
|
when: not matrix_mautrix_hangouts_container_image_self_build
|
||
3 years ago
|
register: result
|
||
|
retries: "{{ matrix_container_retries_count }}"
|
||
|
delay: "{{ matrix_container_retries_delay }}"
|
||
|
until: result is not failed
|
||
5 years ago
|
|
||
5 years ago
|
- name: Ensure Mautrix Hangouts paths exist
|
||
2 years ago
|
ansible.builtin.file:
|
||
5 years ago
|
path: "{{ item.path }}"
|
||
5 years ago
|
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_mautrix_hangouts_base_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_hangouts_config_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_hangouts_data_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_hangouts_docker_src_files_path }}", when: "{{ matrix_mautrix_hangouts_container_image_self_build }}"}
|
||
2 years ago
|
when: "item.when | bool"
|
||
5 years ago
|
|
||
|
- name: Ensure Mautrix Hangots repository is present on self build
|
||
2 years ago
|
ansible.builtin.git:
|
||
4 years ago
|
repo: "{{ matrix_mautrix_hangouts_container_image_self_build_repo }}"
|
||
2 years ago
|
version: "{{ matrix_mautrix_hangouts_container_image_self_build_repo_version }}"
|
||
5 years ago
|
dest: "{{ matrix_mautrix_hangouts_docker_src_files_path }}"
|
||
5 years ago
|
force: "yes"
|
||
3 years ago
|
become: true
|
||
|
become_user: "{{ matrix_user_username }}"
|
||
5 years ago
|
register: matrix_mautrix_hangouts_git_pull_results
|
||
2 years ago
|
when: "matrix_mautrix_hangouts_container_image_self_build | bool"
|
||
5 years ago
|
|
||
5 years ago
|
- name: Ensure Mautrix Hangouts Docker image is built
|
||
2 years ago
|
community.docker.docker_image:
|
||
5 years ago
|
name: "{{ matrix_mautrix_hangouts_docker_image }}"
|
||
|
source: build
|
||
4 years ago
|
force_source: "{{ matrix_mautrix_hangouts_git_pull_results.changed 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_git_pull_results.changed }}"
|
||
5 years ago
|
build:
|
||
|
dockerfile: Dockerfile
|
||
5 years ago
|
path: "{{ matrix_mautrix_hangouts_docker_src_files_path }}"
|
||
3 years ago
|
pull: true
|
||
2 years ago
|
when: "matrix_mautrix_hangouts_container_image_self_build | bool"
|
||
5 years ago
|
|
||
|
- name: Check if an old database file already exists
|
||
2 years ago
|
ansible.builtin.stat:
|
||
5 years ago
|
path: "{{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db"
|
||
|
register: matrix_mautrix_hangouts_stat_database
|
||
|
|
||
|
- name: (Data relocation) Ensure matrix-mautrix-hangouts.service is stopped
|
||
2 years ago
|
ansible.builtin.service:
|
||
5 years ago
|
name: matrix-mautrix-hangouts
|
||
|
state: stopped
|
||
3 years ago
|
enabled: false
|
||
|
daemon_reload: true
|
||
5 years ago
|
failed_when: false
|
||
|
when: "matrix_mautrix_hangouts_stat_database.stat.exists"
|
||
|
|
||
|
- name: (Data relocation) Move mautrix-hangouts database file to ./data directory
|
||
2 years ago
|
ansible.builtin.command: "mv {{ matrix_mautrix_hangouts_base_path }}/mautrix-hangouts.db {{ matrix_mautrix_hangouts_data_path }}/mautrix-hangouts.db"
|
||
5 years ago
|
when: "matrix_mautrix_hangouts_stat_database.stat.exists"
|
||
|
|
||
|
- name: Ensure mautrix-hangouts config.yaml installed
|
||
2 years ago
|
ansible.builtin.copy:
|
||
2 years ago
|
content: "{{ matrix_mautrix_hangouts_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||
5 years ago
|
dest: "{{ matrix_mautrix_hangouts_config_path }}/config.yaml"
|
||
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
5 years ago
|
group: "{{ matrix_user_groupname }}"
|
||
5 years ago
|
|
||
|
- name: Ensure mautrix-hangouts registration.yaml installed
|
||
2 years ago
|
ansible.builtin.copy:
|
||
2 years ago
|
content: "{{ matrix_mautrix_hangouts_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||
5 years ago
|
dest: "{{ matrix_mautrix_hangouts_config_path }}/registration.yaml"
|
||
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
5 years ago
|
group: "{{ matrix_user_groupname }}"
|
||
5 years ago
|
|
||
|
- name: Ensure matrix-mautrix-hangouts.service installed
|
||
2 years ago
|
ansible.builtin.template:
|
||
5 years ago
|
src: "{{ role_path }}/templates/systemd/matrix-mautrix-hangouts.service.j2"
|
||
5 years ago
|
dest: "{{ matrix_systemd_path }}/matrix-mautrix-hangouts.service"
|
||
5 years ago
|
mode: 0644
|
||
|
register: matrix_mautrix_hangouts_systemd_service_result
|
||
|
|
||
|
- name: Ensure systemd reloaded after matrix-mautrix-hangouts.service installation
|
||
2 years ago
|
ansible.builtin.service:
|
||
3 years ago
|
daemon_reload: true
|
||
5 years ago
|
when: "matrix_mautrix_hangouts_systemd_service_result.changed"
|
||
4 years ago
|
|
||
|
- name: Ensure matrix-mautrix-hangouts.service restarted, if necessary
|
||
2 years ago
|
ansible.builtin.service:
|
||
4 years ago
|
name: "matrix-mautrix-hangouts.service"
|
||
|
state: restarted
|
||
2 years ago
|
when: "matrix_mautrix_hangouts_requires_restart | bool"
|