Make Riot-web configuration extensible

Fixes #71 (Github Issue).
This commit is contained in:
Slavi Pantaleev
2019-08-25 10:37:05 +03:00
parent c4eebc5355
commit 0edd7e8089
6 changed files with 86 additions and 2 deletions

View File

@ -43,3 +43,36 @@ matrix_riot_web_registration_enabled: false
# Controls whether Riot shows the presence features
matrix_riot_web_enable_presence_by_hs_url: ~
# Default riot-web configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#
# For a more advanced customization, you can extend the default (see `matrix_riot_web_configuration_extension_json`)
# or completely replace this variable with your own template.
#
# The side-effect of this lookup is that Ansible would even parse the JSON for us, returning a dict.
# This is unlike what it does when looking up YAML template files (no automatic parsing there).
matrix_riot_web_configuration_default: "{{ lookup('template', 'templates/config.json.j2') }}"
# Your custom JSON configuration for riot-web should go to `matrix_riot_web_configuration_extension_json`.
# This configuration extends the default starting configuration (`matrix_riot_web_configuration_default`).
#
# You can override individual variables from the default configuration, or introduce new ones.
#
# If you need something more special, you can take full control by
# completely redefining `matrix_riot_web_configuration_default`.
#
# Example configuration extension follows:
#
# matrix_riot_web_configuration_extension_json: |
# {
# "disable_3pid_login": true,
# "disable_login_language_selector": true
# }
matrix_riot_web_configuration_extension_json: '{}'
matrix_riot_web_configuration_extension: "{{ matrix_riot_web_configuration_extension_json|from_json if matrix_riot_web_configuration_extension_json|from_json is mapping else {} }}"
# Holds the final riot-web configuration (a combination of the default and its extension).
# You most likely don't need to touch this variable. Instead, see `matrix_riot_web_configuration_default`.
matrix_riot_web_configuration: "{{ matrix_riot_web_configuration_default|combine(matrix_riot_web_configuration_extension, recursive=True) }}"

View File

@ -21,6 +21,14 @@
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_riot_web_docker_image_force_pull }}"
when: matrix_riot_web_enabled|bool
- name: Ensure Matrix riot-web configuration installed
copy:
content: "{{ matrix_riot_web_configuration|to_nice_json }}"
dest: "{{ matrix_riot_web_data_path }}/config.json"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_username }}"
- name: Ensure Matrix riot-web config files installed
template:
src: "{{ item.src }}"
@ -29,7 +37,6 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_username }}"
with_items:
- {src: "{{ role_path }}/templates/config.json.j2", name: "config.json"}
- {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
- {src: "{{ role_path }}/templates/welcome.html.j2", name: "welcome.html"}
- {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}

View File

@ -1,4 +1,3 @@
#jinja2: lstrip_blocks: "True"
{
"default_hs_url": {{ matrix_riot_web_default_hs_url|string|to_json }},
"default_is_url": {{ matrix_riot_web_default_is_url|string|to_json }},