mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-06-25 18:57:50 +02:00
added matrix-client-cinny
This commit is contained in:
10
roles/matrix-client-cinny/tasks/init.yml
Normal file
10
roles/matrix-client-cinny/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 Cinny 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_client_cinny_container_image_self_build and matrix_client_cinny_enabled"
|
||||
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-client-cinny.service'] }}"
|
||||
when: matrix_client_cinny_enabled|bool
|
28
roles/matrix-client-cinny/tasks/main.yml
Normal file
28
roles/matrix-client-cinny/tasks/main.yml
Normal file
@ -0,0 +1,28 @@
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_client_cinny_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-client-cinny
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_client_cinny_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-client-cinny
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/self_check.yml"
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
when: "run_self_check|bool and matrix_client_cinny_enabled|bool"
|
||||
tags:
|
||||
- self-check
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_client_cinny_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-client-cinny
|
22
roles/matrix-client-cinny/tasks/self_check.yml
Normal file
22
roles/matrix-client-cinny/tasks/self_check.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
matrix_client_cinny_url_endpoint_public: "https://{{ matrix_server_fqn_cinny }}/config.json"
|
||||
|
||||
- name: Check Cinny
|
||||
uri:
|
||||
url: "{{ matrix_client_cinny_url_endpoint_public }}"
|
||||
follow_redirects: none
|
||||
validate_certs: "{{ matrix_client_cinny_self_check_validate_certificates }}"
|
||||
register: matrix_client_cinny_self_check_result
|
||||
check_mode: no
|
||||
ignore_errors: true
|
||||
|
||||
- name: Fail if Cinny not working
|
||||
fail:
|
||||
msg: "Failed checking Cinny is up at `{{ matrix_server_fqn_cinny }}` (checked endpoint: `{{ matrix_client_cinny_url_endpoint_public }}`). Is Cinny running? Is port 443 open in your firewall? Full error: {{ matrix_client_cinny_self_check_result }}"
|
||||
when: "matrix_client_cinny_self_check_result.failed or 'json' not in matrix_client_cinny_self_check_result"
|
||||
|
||||
- name: Report working Cinny
|
||||
debug:
|
||||
msg: "Cinny at `{{ matrix_server_fqn_cinny }}` is working (checked endpoint: `{{ matrix_client_cinny_url_endpoint_public }}`)"
|
71
roles/matrix-client-cinny/tasks/setup_install.yml
Normal file
71
roles/matrix-client-cinny/tasks/setup_install.yml
Normal file
@ -0,0 +1,71 @@
|
||||
---
|
||||
- name: Ensure Cinny paths exists
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- { path: "{{ matrix_client_cinny_data_path }}", when: true }
|
||||
- { path: "{{ matrix_client_cinny_docker_src_files_path }}", when: "{{ matrix_client_cinny_container_image_self_build }}" }
|
||||
when: "item.when|bool"
|
||||
|
||||
- name: Ensure Cinny Docker image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_client_cinny_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_client_cinny_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_client_cinny_docker_image_force_pull }}"
|
||||
when: "not matrix_client_cinny_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure Cinny repository is present on self-build
|
||||
git:
|
||||
repo: "{{ matrix_client_cinny_container_image_self_build_repo }}"
|
||||
dest: "{{ matrix_client_cinny_docker_src_files_path }}"
|
||||
version: "{{ matrix_client_cinny_docker_image.split(':')[1] }}"
|
||||
force: "yes"
|
||||
register: matrix_client_cinny_git_pull_results
|
||||
when: "matrix_client_cinny_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure Cinny configuration installed
|
||||
copy:
|
||||
content: "{{ matrix_client_cinny_configuration|to_nice_json }}"
|
||||
dest: "{{ matrix_client_cinny_data_path }}/config.json"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure Cinny additional config files installed
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ matrix_client_cinny_data_path }}/{{ item.name }}"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
|
||||
when: "item.src is not none"
|
||||
|
||||
- name: Ensure Cinny Docker image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_client_cinny_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_client_cinny_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_client_cinny_docker_src_files_path }}"
|
||||
pull: yes
|
||||
when: "matrix_client_cinny_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure matrix-client-cinny.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-client-cinny.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-client-cinny.service"
|
||||
mode: 0644
|
||||
register: matrix_client_cinny_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-client-cinny.service installation
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_client_cinny_systemd_service_result.changed|bool"
|
35
roles/matrix-client-cinny/tasks/setup_uninstall.yml
Normal file
35
roles/matrix-client-cinny/tasks/setup_uninstall.yml
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Check existence of matrix-client-cinny.service
|
||||
stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-client-cinny.service"
|
||||
register: matrix_client_cinny_service_stat
|
||||
|
||||
- name: Ensure matrix-client-cinny is stopped
|
||||
service:
|
||||
name: matrix-client-cinny
|
||||
state: stopped
|
||||
enabled: no
|
||||
daemon_reload: yes
|
||||
register: stopping_result
|
||||
when: "matrix_client_cinny_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure matrix-client-cinny.service doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-client-cinny.service"
|
||||
state: absent
|
||||
when: "matrix_client_cinny_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-client-cinny.service removal
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_client_cinny_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure Cinny paths doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_client_cinny_data_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Cinny Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_client_cinny_docker_image }}"
|
||||
state: absent
|
8
roles/matrix-client-cinny/tasks/validate_config.yml
Normal file
8
roles/matrix-client-cinny/tasks/validate_config.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Fail if required Cinny settings not defined
|
||||
fail:
|
||||
msg: >
|
||||
You need to define a required configuration setting (`{{ item }}`) to use Cinny.
|
||||
when: "(vars[item] == '' or vars[item] is none) and matrix_client_cinny_container_image_self_build|bool"
|
||||
with_items:
|
||||
- "matrix_client_cinny_default_hs_url"
|
Reference in New Issue
Block a user