separated livekit and jwt to separate roles

This commit is contained in:
wjbeckett
2024-09-30 22:20:46 +10:00
parent b907777ae5
commit 8cb3e33bbf
29 changed files with 634 additions and 366 deletions

View File

@ -0,0 +1,46 @@
---
# roles/custom/matrix-jwt-service/tasks/install.yml
# Ensure Required Directories Exist
- name: Ensure matrix-jwt-service paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- path: "{{ matrix_jwt_service_base_path }}"
- name: Ensure matrix-jwt-service environment file is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_jwt_service_base_path }}/env"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure JWT Service labels file is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/labels.j2"
dest: "{{ matrix_jwt_service_base_path }}/labels"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
# Ensure Docker Images are Pulled
- name: Ensure jwt-service Docker image is pulled
community.docker.docker_image:
name: "{{ matrix_jwt_service_image }}"
source: pull
register: jwt_image_result
retries: 3
delay: 10
until: jwt_image_result is not failed
# Systemd Services for JWT Service
- name: Ensure jwt-service systemd service is installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-jwt-service.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jwt-service.service"
mode: 0644

View File

@ -0,0 +1,21 @@
---
# Main task file for matrix-element-call
- tags:
- setup-all
- setup-jwt-service
- install-all
- install-wt-service
block:
- when: matrix_jwt_service_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
- when: matrix_jwt_service_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
- tags:
- setup-all
- setup-jwt-service
block:
- when: not matrix_jwt_service_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"

View File

@ -0,0 +1,22 @@
---
# Uninstall tasks for matrix-jwt-service
- name: Stop and remove jwt-service container
community.docker.docker_container:
name: "matrix-jwt-service"
state: absent
- name: Remove jwt-service systemd service
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-jwt-service.service"
state: absent
- name: Remove matrix-jwt-service configuration files
ansible.builtin.file:
path: "{{ matrix_jwt_service_base_path }}"
state: absent
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true

View File

@ -0,0 +1,12 @@
---
# Validate configuration for matrix-jwt-service
- name: Fail if required matrix-jwt-service settings are not defined
ansible.builtin.fail:
msg: >
You need to define a required configuration setting (`{{ item.name }}`).
when: "item.when | bool and vars[item.name] == ''"
with_items:
- {'name': 'matrix_jwt_service_base_path', when: true}
- {'name': 'matrix_jwt_service_container_network', when: true}
- {'name': 'matrix_jwt_service_image', when: true}