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

@ -1,22 +0,0 @@
---
---
# Create the element.json file to point to Element Call
- name: Ensure .well-known/element directory exists
ansible.builtin.file:
path: "{{ matrix_element_call_well_known_element_path | dirname }}"
state: directory
mode: 0755
- name: Create or update the element.json file with Element Call config
ansible.builtin.copy:
dest: "{{ matrix_element_call_well_known_element_path }}"
content: |
{
"call": {
"widget_url": "{{ matrix_element_call_base_url }}"
}
}
mode: '0644'
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

View File

@ -175,7 +175,7 @@
"org.matrix.msc4143.rtc_foci": [
{
"type": "livekit",
"livekit_service_url": "{{ matrix_element_call_jwt_service_url }}"
"livekit_service_url": "{{ matrix_jwt_service_url }}"
}
]
marker: "# ANSIBLE MANAGED BLOCK - Element Call RTC FOCI"

View File

@ -1,166 +0,0 @@
---
# Ensure Required Directories Exist
- name: Ensure matrix-element-call paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
loop:
- path: "{{ matrix_element_call_base_path }}"
- path: "{{ matrix_element_call_base_path }}/data"
- path: "{{ matrix_element_call_base_path }}/config"
- path: "{{ matrix_element_call_base_path }}/backend" # For LiveKit and Redis config
# Ensure Configuration Files are in Place
- name: Ensure Element Call config.json is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/config.json.j2"
dest: "{{ matrix_element_call_base_path }}/config/config.json"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure LiveKit livekit.yaml is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/livekit.yaml.j2"
dest: "{{ matrix_element_call_base_path }}/backend/livekit.yaml"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure Redis redis.conf is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/redis.conf.j2"
dest: "{{ matrix_element_call_base_path }}/backend/redis.conf"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-element-call environment file is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_element_call_base_path }}/config/env"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-element-call Docker labels file is in place
ansible.builtin.template:
src: "{{ role_path }}/templates/labels.j2"
dest: "{{ matrix_element_call_base_path }}/config/labels"
mode: 0640
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
# Ensure Docker Images are Pulled
- name: Ensure matrix-element-call Docker image is pulled
community.docker.docker_image:
name: "{{ matrix_element_call_image }}"
source: pull
force_source: "{{ matrix_element_call_container_image_force_pull }}"
register: element_call_image_result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: element_call_image_result is not failed
- name: Ensure jwt-service Docker image is pulled
community.docker.docker_image:
name: "ghcr.io/element-hq/lk-jwt-service:latest-ci"
source: pull
register: jwt_image_result
retries: 3
delay: 10
until: jwt_image_result is not failed
- name: Ensure livekit Docker image is pulled
community.docker.docker_image:
name: "livekit/livekit-server:latest"
source: pull
register: livekit_image_result
retries: 3
delay: 10
until: livekit_image_result is not failed
- name: Ensure redis Docker image is pulled
community.docker.docker_image:
name: "redis:6-alpine"
source: pull
register: redis_image_result
retries: 3
delay: 10
until: redis_image_result is not failed
- name: Debug matrix_element_call_base_path
ansible.builtin.debug:
var: matrix_element_call_base_path
- name: Debug labels file content
ansible.builtin.debug:
msg: "{{ lookup('file', matrix_element_call_base_path ~ '/config/labels') | from_yaml }}"
# Ensure Docker Containers are Running
- name: Run matrix-element-call Docker container
community.docker.docker_container:
name: "matrix-element-call"
image: "{{ matrix_element_call_image }}"
state: started
restart_policy: unless-stopped
env_file: "{{ matrix_element_call_base_path }}/config/env"
labels: "{{ lookup('file', matrix_element_call_base_path ~ '/config/labels') | from_yaml }}"
networks:
- name: "{{ matrix_element_call_container_network }}"
volumes:
- "{{ matrix_element_call_base_path }}/config/config.json:/app/config.json"
- "{{ matrix_element_call_base_path }}/data:/data"
- name: Run jwt-service Docker container
community.docker.docker_container:
name: "matrix-jwt-service"
image: "ghcr.io/element-hq/lk-jwt-service:latest-ci"
state: started
restart_policy: unless-stopped
environment:
LIVEKIT_SECRET: "{{ matrix_element_call_livekit_dev_key }}" # User-specified key
LIVEKIT_URL: "{{ matrix_element_call_livekit_service_url }}"
LIVEKIT_KEY: "devkey"
networks:
- name: "{{ matrix_element_call_container_network }}"
- name: Run livekit Docker container
community.docker.docker_container:
name: "matrix-livekit"
image: "livekit/livekit-server:latest"
state: started
restart_policy: unless-stopped
command: "--dev --config /etc/livekit.yaml"
volumes:
- "{{ matrix_element_call_base_path }}/backend/livekit.yaml:/etc/livekit.yaml"
network_mode: "host"
- name: Run redis Docker container
community.docker.docker_container:
name: "matrix-redis"
image: "redis:6-alpine"
state: started
restart_policy: unless-stopped
command: redis-server /etc/redis.conf
volumes:
- "{{ matrix_element_call_base_path }}/backend/redis.conf:/etc/redis.conf"
networks:
- name: "{{ matrix_element_call_container_network }}"
# Ensure Systemd Services are Set Up
- name: Ensure matrix-element-call systemd service is installed
ansible.builtin.template:
src: "{{ role_path }}/templates/element-call.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-element-call.service"
mode: 0644
- name: Ensure matrix-element-call systemd service is enabled and started
ansible.builtin.systemd:
name: matrix-element-call
enabled: true
state: started
daemon_reload: true

View File

@ -1,29 +0,0 @@
---
# Update Element-Web config.json with Element Call features
- name: Ensure Element-Web config.json exists
ansible.builtin.file:
path: "{{ matrix_element_web_config_path }}"
state: file
mode: 0644
- name: Update Element-Web config.json with Element Call features
ansible.builtin.blockinfile:
path: "{{ matrix_element_web_config_path }}"
block: |
"features": {
"feature_video_rooms": true,
"feature_new_room_decoration_ui": true,
"feature_group_calls": true,
"feature_element_call_video_rooms": true
},
"element_call": {
"url": "{{ matrix_element_call_base_url }}",
"participant_limit": 8,
"brand": "Element Call",
"use_exclusively": true
}
marker: "# ANSIBLE MANAGED BLOCK - Element Call features"
mode: '0644'
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

View File

@ -1,36 +0,0 @@
---
# Update the homeserver.yaml file with Element Call config
- name: Ensure homeserver.yaml exists
ansible.builtin.file:
path: "{{ matrix_homeserver_config_path }}"
state: file
mode: 0644
- name: Add listeners section for Element Call to homeserver.yaml
ansible.builtin.blockinfile:
path: "{{ matrix_homeserver_config_path }}"
block: |
listeners:
- port: 8008
tls: false
type: http
x_forwarded: true
resources:
- names: [client, federation, openid]
compress: false
marker: "# ANSIBLE MANAGED BLOCK - Element Call listeners"
mode: '0644'
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure serve_server_wellknown is enabled in homeserver.yaml
ansible.builtin.lineinfile:
path: "{{ matrix_homeserver_config_path }}"
line: "serve_server_wellknown: true"
insertafter: EOF
state: present
mode: '0644'
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

View File

@ -1,24 +0,0 @@
---
---
# Update the .well-known/matrix/client file with Element Call config
- name: Ensure .well-known directory exists
ansible.builtin.file:
path: "{{ matrix_element_call_well_known_client_path | dirname }}"
state: directory
mode: 0755
- name: Update .well-known/matrix/client file with Element Call config
ansible.builtin.blockinfile:
path: "{{ matrix_element_call_well_known_client_path }}"
block: |
"org.matrix.msc4143.rtc_foci": [
{
"type": "livekit",
"livekit_service_url": "{{ matrix_element_call_jwt_service_url }}"
}
]
create: yes
mode: '0644'
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

View File

@ -14,4 +14,4 @@
- {'name': 'matrix_livekit_image', when: true}
- {'name': 'redis_image', when: true}
- {'name': 'matrix_element_call_livekit_dev_key', when: true}
- {'name': 'matrix_element_call_livekit_service_url', when: true}
- {'name': 'matrix_jwt_service_url', when: true}