sync with previous repo
This commit is contained in:
10
roles/matrix-corporal/tasks/init.yml
Normal file
10
roles/matrix-corporal/tasks/init.yml
Normal file
@ -0,0 +1,10 @@
|
||||
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
|
||||
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
|
||||
- name: Fail if trying to self-build on Ansible < 2.8
|
||||
fail:
|
||||
msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md"
|
||||
when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_corporal_container_image_self_build and matrix_corporal_enabled"
|
||||
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-corporal.service'] }}"
|
||||
when: matrix_corporal_enabled|bool
|
22
roles/matrix-corporal/tasks/main.yml
Normal file
22
roles/matrix-corporal/tasks/main.yml
Normal file
@ -0,0 +1,22 @@
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_corporal_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-corporal
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_corporal.yml"
|
||||
when: run_setup|bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-corporal
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/self_check_corporal.yml"
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
when: "run_self_check|bool and matrix_corporal_enabled|bool"
|
||||
tags:
|
||||
- self-check
|
22
roles/matrix-corporal/tasks/self_check_corporal.yml
Normal file
22
roles/matrix-corporal/tasks/self_check_corporal.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
corporal_client_api_url_endpoint_public: "https://{{ matrix_server_fqn_matrix }}/_matrix/client/corporal"
|
||||
|
||||
- name: Check Matrix Corporal HTTP gateway
|
||||
uri:
|
||||
url: "{{ corporal_client_api_url_endpoint_public }}"
|
||||
follow_redirects: none
|
||||
return_content: true
|
||||
check_mode: no
|
||||
register: result_corporal_client_api
|
||||
ignore_errors: true
|
||||
|
||||
- name: Fail if Matrix Corporal HTTP gateway not working
|
||||
fail:
|
||||
msg: "Failed checking Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ corporal_client_api_url_endpoint_public }}`). Is matrix-corporal running? Is port 443 open in your firewall? Full error: {{ result_corporal_client_api }}"
|
||||
when: "result_corporal_client_api.failed or 'Matrix Client-Server API protected by Matrix Corporal' not in result_corporal_client_api.content"
|
||||
|
||||
- name: Report working Matrix Corporal HTTP gateway
|
||||
debug:
|
||||
msg: "Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ corporal_client_api_url_endpoint_public }}`)"
|
114
roles/matrix-corporal/tasks/setup_corporal.yml
Normal file
114
roles/matrix-corporal/tasks/setup_corporal.yml
Normal file
@ -0,0 +1,114 @@
|
||||
---
|
||||
|
||||
#
|
||||
# Tasks related to setting up matrix-corporal
|
||||
#
|
||||
|
||||
- name: Ensure Matrix Corporal paths exist
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- "{{ matrix_corporal_config_dir_path }}"
|
||||
- "{{ matrix_corporal_cache_dir_path }}"
|
||||
- "{{ matrix_corporal_var_dir_path }}"
|
||||
when: matrix_corporal_enabled|bool
|
||||
|
||||
- name: Ensure Matrix Corporal repository is present on self-build
|
||||
git:
|
||||
repo: "{{ matrix_corporal_container_image_self_build_repo }}"
|
||||
dest: "{{ matrix_corporal_container_src_files_path }}"
|
||||
version: "{{ matrix_corporal_docker_image.split(':')[1] }}"
|
||||
force: "yes"
|
||||
register: matrix_corporal_git_pull_results
|
||||
when: "matrix_corporal_enabled|bool and matrix_corporal_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure Matrix Corporal Docker image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_corporal_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_corporal_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_corporal_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: etc/docker/Dockerfile
|
||||
path: "{{ matrix_corporal_container_src_files_path }}"
|
||||
pull: yes
|
||||
when: "matrix_corporal_enabled|bool and matrix_corporal_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure Matrix Corporal Docker image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_corporal_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_corporal_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_corporal_docker_image_force_pull }}"
|
||||
when: "matrix_corporal_enabled|bool and not matrix_corporal_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure Matrix Corporal config installed
|
||||
copy:
|
||||
content: "{{ matrix_corporal_configuration|to_nice_json }}"
|
||||
dest: "{{ matrix_corporal_config_dir_path }}/config.json"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
when: matrix_corporal_enabled|bool
|
||||
|
||||
- name: Ensure matrix-corporal.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-corporal.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-corporal.service"
|
||||
mode: 0644
|
||||
register: matrix_corporal_systemd_service_result
|
||||
when: matrix_corporal_enabled|bool
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-corporal.service installation
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_corporal_enabled|bool and matrix_corporal_systemd_service_result.changed"
|
||||
|
||||
|
||||
#
|
||||
# Tasks related to getting rid of matrix-corporal (if it was previously enabled)
|
||||
#
|
||||
|
||||
- name: Check existence of matrix-corporal service
|
||||
stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-corporal.service"
|
||||
register: matrix_corporal_service_stat
|
||||
when: "not matrix_corporal_enabled|bool"
|
||||
|
||||
- name: Ensure matrix-corporal is stopped
|
||||
service:
|
||||
name: matrix-corporal
|
||||
state: stopped
|
||||
daemon_reload: yes
|
||||
register: stopping_result
|
||||
when: "not matrix_corporal_enabled|bool and matrix_corporal_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-corporal.service doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-corporal.service"
|
||||
state: absent
|
||||
when: "not matrix_corporal_enabled|bool and matrix_corporal_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-corporal.service removal
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "not matrix_corporal_enabled|bool and matrix_corporal_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-corporal files don't exist
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ matrix_systemd_path }}/matrix-corporal.service"
|
||||
- "{{ matrix_corporal_config_dir_path }}/config.json"
|
||||
when: "not matrix_corporal_enabled|bool"
|
||||
|
||||
- name: Ensure Matrix Corporal Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_corporal_docker_image }}"
|
||||
state: absent
|
||||
when: "not matrix_corporal_enabled|bool"
|
27
roles/matrix-corporal/tasks/validate_config.yml
Normal file
27
roles/matrix-corporal/tasks/validate_config.yml
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
|
||||
- name: Fail if required matrix-corporal settings not defined
|
||||
fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`) for using matrix-corporal.
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_corporal_matrix_homeserver_api_endpoint"
|
||||
- "matrix_corporal_matrix_auth_shared_secret"
|
||||
- "matrix_corporal_matrix_registration_shared_secret"
|
||||
- "matrix_corporal_policy_provider_config"
|
||||
|
||||
- name: Fail if HTTP API enabled, but no token set
|
||||
fail:
|
||||
msg: "The Matrix Corporal HTTP API is enabled (`matrix_corporal_http_api_enabled`), but no auth token has been set in `matrix_corporal_http_api_auth_token`"
|
||||
when: "matrix_corporal_http_api_enabled|bool and matrix_corporal_http_api_auth_token == ''"
|
||||
|
||||
- name: (Deprecation) Catch and report renamed corporal variables
|
||||
fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
|
||||
when: "item.old in vars"
|
||||
with_items:
|
||||
- {'old': 'matrix_corporal_container_expose_ports', 'new': '<superseded by matrix_corporal_container_http_gateway_host_bind_port and matrix_corporal_container_http_api_host_bind_port>'}
|
||||
- {'old': 'matrix_corporal_reconciliation_user_id_local_part', 'new': 'matrix_corporal_corporal_user_id_local_part'}
|
Reference in New Issue
Block a user