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.
95 lines
4.1 KiB
95 lines
4.1 KiB
4 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:
|
||
4 years ago
|
msg: >-
|
||
4 years ago
|
The matrix-bridge-mautrix-twitter role needs to execute before the matrix-synapse role.
|
||
2 years ago
|
when: "matrix_synapse_role_executed | default(False)"
|
||
4 years ago
|
|
||
2 years ago
|
- ansible.builtin.set_fact:
|
||
4 years ago
|
matrix_mautrix_twitter_requires_restart: false
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure Mautrix Twitter image is pulled
|
||
2 years ago
|
community.docker.docker_image:
|
||
4 years ago
|
name: "{{ matrix_mautrix_twitter_docker_image }}"
|
||
4 years ago
|
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||
4 years ago
|
force_source: "{{ matrix_mautrix_twitter_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_twitter_docker_image_force_pull }}"
|
||
2 years ago
|
when: matrix_mautrix_twitter_enabled | bool and not matrix_mautrix_twitter_container_image_self_build
|
||
3 years ago
|
register: result
|
||
|
retries: "{{ matrix_container_retries_count }}"
|
||
|
delay: "{{ matrix_container_retries_delay }}"
|
||
|
until: result is not failed
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure Mautrix Twitter paths exist
|
||
2 years ago
|
ansible.builtin.file:
|
||
4 years ago
|
path: "{{ item.path }}"
|
||
|
state: directory
|
||
|
mode: 0750
|
||
|
owner: "{{ matrix_user_username }}"
|
||
|
group: "{{ matrix_user_groupname }}"
|
||
|
with_items:
|
||
3 years ago
|
- {path: "{{ matrix_mautrix_twitter_base_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_twitter_config_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_twitter_data_path }}", when: true}
|
||
|
- {path: "{{ matrix_mautrix_twitter_docker_src_files_path }}", when: "{{ matrix_mautrix_twitter_container_image_self_build }}"}
|
||
2 years ago
|
when: item.when | bool
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure Mautrix Twitter repository is present on self-build
|
||
2 years ago
|
ansible.builtin.git:
|
||
4 years ago
|
repo: "{{ matrix_mautrix_twitter_container_image_self_build_repo }}"
|
||
2 years ago
|
version: "{{ matrix_mautrix_twitter_container_image_self_build_repo_version }}"
|
||
4 years ago
|
dest: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
|
||
4 years ago
|
force: "yes"
|
||
3 years ago
|
become: true
|
||
|
become_user: "{{ matrix_user_username }}"
|
||
4 years ago
|
register: matrix_mautrix_twitter_git_pull_results
|
||
2 years ago
|
when: "matrix_mautrix_twitter_enabled | bool and matrix_mautrix_twitter_container_image_self_build"
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure Mautrix Twitter Docker image is built
|
||
2 years ago
|
community.docker.docker_image:
|
||
4 years ago
|
name: "{{ matrix_mautrix_twitter_docker_image }}"
|
||
4 years ago
|
source: build
|
||
4 years ago
|
force_source: "{{ matrix_mautrix_twitter_git_pull_results.changed }}"
|
||
4 years ago
|
build:
|
||
|
dockerfile: Dockerfile
|
||
4 years ago
|
path: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
|
||
3 years ago
|
pull: true
|
||
2 years ago
|
when: "matrix_mautrix_twitter_enabled | bool and matrix_mautrix_twitter_container_image_self_build | bool"
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure mautrix-twitter config.yaml installed
|
||
2 years ago
|
ansible.builtin.copy:
|
||
2 years ago
|
content: "{{ matrix_mautrix_twitter_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||
4 years ago
|
dest: "{{ matrix_mautrix_twitter_config_path }}/config.yaml"
|
||
4 years ago
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
|
group: "{{ matrix_user_groupname }}"
|
||
|
|
||
4 years ago
|
- name: Ensure mautrix-twitter registration.yaml installed
|
||
2 years ago
|
ansible.builtin.copy:
|
||
2 years ago
|
content: "{{ matrix_mautrix_twitter_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||
4 years ago
|
dest: "{{ matrix_mautrix_twitter_config_path }}/registration.yaml"
|
||
4 years ago
|
mode: 0644
|
||
|
owner: "{{ matrix_user_username }}"
|
||
|
group: "{{ matrix_user_groupname }}"
|
||
|
|
||
4 years ago
|
- name: Ensure matrix-mautrix-twitter.service installed
|
||
2 years ago
|
ansible.builtin.template:
|
||
4 years ago
|
src: "{{ role_path }}/templates/systemd/matrix-mautrix-twitter.service.j2"
|
||
|
dest: "{{ matrix_systemd_path }}/matrix-mautrix-twitter.service"
|
||
4 years ago
|
mode: 0644
|
||
4 years ago
|
register: matrix_mautrix_twitter_systemd_service_result
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure systemd reloaded after matrix-mautrix-twitter.service installation
|
||
2 years ago
|
ansible.builtin.service:
|
||
3 years ago
|
daemon_reload: true
|
||
4 years ago
|
when: "matrix_mautrix_twitter_systemd_service_result.changed"
|
||
4 years ago
|
|
||
4 years ago
|
- name: Ensure matrix-mautrix-twitter.service restarted, if necessary
|
||
2 years ago
|
ansible.builtin.service:
|
||
4 years ago
|
name: "matrix-mautrix-twitter.service"
|
||
4 years ago
|
state: restarted
|
||
2 years ago
|
when: "matrix_mautrix_twitter_requires_restart | bool"
|