Add livekit_server_identifier

This commit is contained in:
Slavi Pantaleev
2024-11-21 16:54:45 +02:00
parent fa4ebd2a64
commit 783d4a23f8
9 changed files with 46 additions and 52 deletions

View File

@ -1,8 +1,6 @@
---
# roles/custom/matrix-livekit-server/tasks/install.yml
# Ensure Required Directories Exist
- name: Ensure matrix-livekit-server paths exist
- name: Ensure LiveKit Server paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
@ -12,8 +10,7 @@
with_items:
- path: "{{ livekit_server_base_path }}"
# Ensure Configuration Files are in Place
- name: Ensure LiveKit livekit.yaml is in place
- name: Ensure LiveKit Server livekit.yaml is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/livekit.yaml.j2"
dest: "{{ livekit_server_base_path }}/livekit.yaml"
@ -21,7 +18,7 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure LiveKit labels file is in place
- name: Ensure LiveKit Server labels file is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/labels.j2"
dest: "{{ livekit_server_base_path }}/labels"
@ -29,8 +26,7 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
# Ensure Docker Images are Pulled
- name: Ensure LiveKit Docker image is pulled
- name: Ensure LiveKit Server container image is pulled
community.docker.docker_image:
name: "{{ livekit_server_container_image }}"
source: pull
@ -39,9 +35,8 @@
delay: 10
until: livekit_image_result is not failed
# Systemd Services for LiveKit
- name: Ensure LiveKit systemd service is installed
- name: Ensure LiveKit Server systemd service is installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-livekit-server.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-livekit-server.service"
src: "{{ role_path }}/templates/systemd/livekit-server.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ livekit_server_identifier }}.service"
mode: 0644

View File

@ -1,5 +1,4 @@
---
# Main task file for matrix-livekit-server
- tags:
- setup-all

View File

@ -1,21 +1,25 @@
---
# Uninstall tasks for matrix-livekit-server
- name: Stop and remove LiveKit container
community.docker.docker_container:
name: "matrix-livekit-server"
state: absent
- name: Check existence of LiveKit Server service
ansible.builtin.stat:
path: "{{ devture_systemd_docker_base_systemd_path }}/{{ livekit_server_identifier }}.service"
register: livekit_server_service_stat
- name: Remove LiveKit systemd service
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-livekit-server.service"
state: absent
- when: livekit_server_service_stat.stat.exists | bool
block:
- name: Ensure LiveKit Server is stopped
ansible.builtin.service:
name: "{{ livekit_server_identifier }}"
state: stopped
enabled: false
daemon_reload: true
- name: Remove matrix-livekit-server configuration files
ansible.builtin.file:
path: "{{ matrix_livekit_serverbase_path }}"
state: absent
- name: Ensure LiveKit Server systemd service doesn't exist
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/{{ livekit_server_identifier }}.service"
state: absent
- name: Reload systemd daemon
ansible.builtin.systemd:
daemon_reload: true
- name: Ensure LiveKit Server paths don't exist
ansible.builtin.file:
path: "{{ livekit_server_base_path }}"
state: absent

View File

@ -1,14 +1,13 @@
---
# Validate configuration for matrix-livekit-server
- name: Fail if required matrix-livekit-server settings are not defined
- name: Fail if required LiveKit Server 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] == ''"
when: "item.when | bool and vars[item.name] | length == 0"
with_items:
- {'name': 'livekit_server_hostname', when: true}
- {'name': 'livekit_server_base_path', when: true}
- {'name': 'livekit_server_container_network', when: true}
- {'name': 'livekit_server_container_image', when: true}
- {'name': 'livekit_server_container_image', when: true}
- {'name': 'livekit_server_config_keys_devkey', when: true}