feat: include matrix_ldap_registration_proxy

Fixes: #1144

Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
TheOneWithTheBraid
2022-08-21 11:04:47 +02:00
parent bab0d3b2cf
commit 6f02a916ec
10 changed files with 289 additions and 0 deletions

View File

@ -0,0 +1,11 @@
---
# 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
ansible.builtin.fail:
msg: "To self-build the matrix_ldap_registration_proxy 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_matrix_ldap_registration_proxy_container_image_self_build and matrix_matrix_ldap_registration_proxy_enabled | bool"
- ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-matrix-ldap-registration-proxy.service'] }}"
when: matrix_matrix_ldap_registration_proxy_enabled | bool

View File

@ -0,0 +1,30 @@
---
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags:
- always
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup | bool and matrix_matrix_ldap_registration_proxy_enabled | bool"
tags:
- setup-all
- setup-matrix-ldap-registration-proxy
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup | bool and matrix_matrix_ldap_registration_proxy_enabled | bool"
tags:
- setup-all
- setup-matrix-ldap-registration-proxy
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup | bool and not matrix_matrix_ldap_registration_proxy_enabled | bool"
tags:
- setup-all
- setup-matrix-ldap-registration-proxy
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/self_check_matrix_ldap_registration_proxy.yml"
delegate_to: 127.0.0.1
become: false
when: "run_self_check | bool and matrix_matrix_ldap_registration_proxy_enabled | bool"
tags:
- self-check

View File

@ -0,0 +1,22 @@
---
- ansible.builtin.set_fact:
matrix_ldap_registration_proxy_url_endpoint_public: "https://{{ matrix_server_fqn_matrix }}/_matrix/client/r0/register"
- name: Check matrix_ldap_registration_proxy Service
ansible.builtin.uri:
url: "{{ matrix_ldap_registration_proxy_url_endpoint_public }}"
follow_redirects: none
validate_certs: "{{ matrix_matrix_ldap_registration_proxy_self_check_validate_certificates }}"
check_mode: false
register: result_matrix_ldap_registration_proxy
ignore_errors: true
- name: Fail if matrix_ldap_registration_proxy Service not working
ansible.builtin.fail:
msg: "Failed checking matrix_ldap_registration_proxy is up at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_ldap_registration_proxy_url_endpoint_public }}`). Is matrix_ldap_registration_proxy running? Is port 443 open in your firewall? Full error: {{ result_matrix_ldap_registration_proxy }}"
when: "result_matrix_ldap_registration_proxy.failed or 'json' not in result_matrix_ldap_registration_proxy"
- name: Report working matrix_ldap_registration_proxy Service
ansible.builtin.debug:
msg: "matrix_ldap_registration_proxy at `{{ matrix_server_fqn_matrix }}` is working (checked endpoint: `{{ matrix_ldap_registration_proxy_url_endpoint_public }}`)"

View File

@ -0,0 +1,63 @@
---
- name: Ensure matrix_ldap_registration_proxy paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- {path: "{{ matrix_ldap_registration_proxy_config_path }}", when: true}
- {path: "{{ matrix_ldap_registration_proxy_docker_src_files_path }}", when: true}
when: "item.when | bool"
- ansible.builtin.set_fact:
matrix_ldap_registration_proxy_requires_restart: false
- name: Ensure matrix_ldap_registration_proxy repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_ldap_registration_proxy_container_image_self_build_repo }}"
dest: "{{ matrix_ldap_registration_proxy_docker_src_files_path }}"
version: "{{ matrix_ldap_registration_proxy_container_image_self_build_branch }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_ldap_registration_proxy_git_pull_results
- name: Ensure matrix_ldap_registration_proxy Docker image is built
docker_image:
name: "{{ matrix_ldap_registration_proxy_docker_image }}"
source: build
force_source: "{{ matrix_ldap_registration_proxy_git_pull_results.changed }}"
build:
dockerfile: Dockerfile
path: "{{ matrix_ldap_registration_proxy_docker_src_files_path }}"
pull: true
when: true
- name: Ensure matrix_ldap_registration_proxy config installed
ansible.builtin.copy:
content: "{{ matrix_ldap_registration_proxy_configuration }}"
dest: "{{ matrix_ldap_registration_proxy_config_path }}/ldap-registration-proxy.env"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-ldap-registration-proxy.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-ldap-registration-proxy.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-ldap-registration-proxy.service"
mode: 0644
register: matrix_ldap_registration_proxy_systemd_service_result
- name: Ensure systemd reloaded after matrix-ldap-registration-proxy.service installation
ansible.builtin.service:
daemon_reload: true
when: "matrix_ldap_registration_proxy_systemd_service_result.changed | bool"
- name: Ensure matrix-ldap-registration-proxy.service restarted, if necessary
ansible.builtin.service:
name: "matrix-ldap-registration-proxy.service"
state: restarted
when: "matrix_ldap_registration_proxy_requires_restart | bool"

View File

@ -0,0 +1,36 @@
---
- name: Check existence of matrix-matrix_ldap_registration_proxy service
ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-ldap-registration-proxy.service"
register: matrix_matrix_ldap_registration_proxy_service_stat
- name: Ensure matrix-matrix_ldap_registration_proxy is stopped
ansible.builtin.service:
name: matrix-matrix_ldap_registration_proxy
state: stopped
enabled: false
daemon_reload: true
register: stopping_result
when: "matrix_matrix_ldap_registration_proxy_service_stat.stat.exists | bool"
- name: Ensure matrix-ldap-registration-proxy.service doesn't exist
ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-ldap-registration-proxy.service"
state: absent
when: "matrix_matrix_ldap_registration_proxy_service_stat.stat.exists | bool"
- name: Ensure systemd reloaded after matrix-ldap-registration-proxy.service removal
ansible.builtin.service:
daemon_reload: true
when: "matrix_matrix_ldap_registration_proxy_service_stat.stat.exists | bool"
- name: Ensure Matrix matrix_ldap_registration_proxy paths don't exist
ansible.builtin.file:
path: "{{ matrix_matrix_ldap_registration_proxy_base_path }}"
state: absent
- name: Ensure matrix_ldap_registration_proxy Docker image doesn't exist
docker_image:
name: "{{ matrix_matrix_ldap_registration_proxy_docker_image }}"
state: absent