From a6e3203398fbb6c28a98127ca59ed8ad112ca68c Mon Sep 17 00:00:00 2001 From: wjbeckett Date: Tue, 1 Oct 2024 22:20:50 +1000 Subject: [PATCH] updated docs, broke the well-known and element client modifications out to separate tasks. --- docs/configuring-playbook-element-call.md | 14 ++----- .../matrix-element-call/defaults/main.yml | 2 +- .../matrix-element-call/tasks/install.yml | 40 ++++--------------- .../tasks/update_element_web_config.yml | 27 +++++++++++++ .../tasks/update_well_known_client.yml | 21 ++++++++++ 5 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 roles/custom/matrix-element-call/tasks/update_element_web_config.yml create mode 100644 roles/custom/matrix-element-call/tasks/update_well_known_client.yml diff --git a/docs/configuring-playbook-element-call.md b/docs/configuring-playbook-element-call.md index bd36357ab..188b06d5e 100644 --- a/docs/configuring-playbook-element-call.md +++ b/docs/configuring-playbook-element-call.md @@ -28,21 +28,15 @@ Ensure that the following DNS names have a public IP/FQDN: Add the following configuration to your `inventory/host_vars/matrix.DOMAIN/vars.yml` file: ```yaml +# Enable dependent services +keydb_enabled: true matrix_element_call_enabled: true +matrix_livekit_server_enabled: true +matrix_jwt_service_enabled: true # Set a secure key for LiveKit authentication matrix_element_call_livekit_dev_key: 'your-secure-livekit-key' ``` -## External databases - -If your setup utilizes an external database, you may need to adjust the default configuration for Redis used by Element Call. Modify the defaults in group_vars/matrix_servers.yml or host_vars to suit your setup: - -```yaml -matrix_element_call_redis_hostname: 'localhost' -matrix_element_call_redis_port: 6379 -matrix_element_call_redis_password: '' -``` - ## Installing After potentially adjusting DNS records and configuring the playbook, run the installation command again: ```yaml diff --git a/roles/custom/matrix-element-call/defaults/main.yml b/roles/custom/matrix-element-call/defaults/main.yml index 0a227a1bc..02c910734 100644 --- a/roles/custom/matrix-element-call/defaults/main.yml +++ b/roles/custom/matrix-element-call/defaults/main.yml @@ -5,7 +5,7 @@ matrix_element_call_enabled: false # Base path configuration matrix_element_call_base_path: "{{ matrix_base_data_path }}/element-call" matrix_homeserver_config_path: "{{ matrix_base_data_path }}/synapse/config/homeserver.yaml" -element_web_config_path: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" +element_web_config_path: "{{ matrix_base_data_path }}/client-element/config.json" # Docker network configuration matrix_element_call_container_network: '' diff --git a/roles/custom/matrix-element-call/tasks/install.yml b/roles/custom/matrix-element-call/tasks/install.yml index 266a9407b..2c7aebf38 100644 --- a/roles/custom/matrix-element-call/tasks/install.yml +++ b/roles/custom/matrix-element-call/tasks/install.yml @@ -79,20 +79,10 @@ when: matrix_element_call_enabled | bool # Update the well-known client file for Element Call (adding RTC FOCI) -- name: Update the existing well-known client file for Element Call (RTC FOCI) - ansible.builtin.blockinfile: - path: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" - block: | - "org.matrix.msc4143.rtc_foci": [ - { - "type": "livekit", - "livekit_service_url": "{{ matrix_jwt_service_url }}" - } - ] - marker: "# ANSIBLE MANAGED BLOCK - Element Call RTC FOCI" - mode: '0644' - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" +- name: Update the well-known client file for Element Call + ansible.builtin.include_tasks: update_well_known_client.yml + when: matrix_element_call_enabled | bool + # Create .well-known/element/element.json for Element Call - name: Create the well-known element.json file @@ -105,22 +95,6 @@ # Update Element Web config.json with Element Call settings - name: Update Element Web config.json - ansible.builtin.blockinfile: - path: "{{ 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": "https://{{ matrix_element_call_domain }}", - "participant_limit": 8, - "brand": "Element Call", - "use_exclusively": true - } - marker: "# ANSIBLE MANAGED BLOCK - Element Call settings" - mode: '0644' - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_groupname }}" + ansible.builtin.include_tasks: "tasks/update_element_web_config.yml" + when: matrix_element_call_enabled | bool + diff --git a/roles/custom/matrix-element-call/tasks/update_element_web_config.yml b/roles/custom/matrix-element-call/tasks/update_element_web_config.yml new file mode 100644 index 000000000..3025b432e --- /dev/null +++ b/roles/custom/matrix-element-call/tasks/update_element_web_config.yml @@ -0,0 +1,27 @@ +- name: Update Element Web config.json settings + vars: + additional_settings: | + { + "features": { + "feature_video_rooms": true, + "feature_new_room_decoration_ui": true, + "feature_group_calls": true, + "feature_element_call_video_rooms": true + }, + "element_call": { + "url": "https://{{ matrix_element_call_domain }}", + "participant_limit": 8, + "brand": "Element Call", + "use_exclusively": true + } + } + set_fact: + updated_element_web_config: "{{ (element_web_config_content.content | b64decode | from_json) | combine(additional_settings | from_json, recursive=True) }}" + +- name: Write updated Element Web config.json + copy: + content: "{{ updated_element_web_config | to_nice_json }}" + dest: "{{ element_web_config_path }}" + mode: '0644' + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" diff --git a/roles/custom/matrix-element-call/tasks/update_well_known_client.yml b/roles/custom/matrix-element-call/tasks/update_well_known_client.yml new file mode 100644 index 000000000..96d568c4c --- /dev/null +++ b/roles/custom/matrix-element-call/tasks/update_well_known_client.yml @@ -0,0 +1,21 @@ +--- +- name: Read the existing well-known client file + ansible.builtin.slurp: + path: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" + register: client_file_content + +- name: Load the existing JSON content + ansible.builtin.set_fact: + client_json: "{{ client_file_content['content'] | b64decode | from_json }}" + +- name: Update the existing well-known client file for Element Call (RTC FOCI) + ansible.builtin.set_fact: + updated_client_json: "{{ client_json | combine({'org.matrix.msc4143.rtc_foci': [{'type': 'livekit', 'livekit_service_url': matrix_jwt_service_url}]}, recursive=True) }}" + +- name: Write the updated well-known client file + ansible.builtin.copy: + content: "{{ updated_client_json | to_nice_json }}" + dest: "{{ matrix_base_data_path }}/static-files/public/.well-known/matrix/client" + mode: '0644' + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}"