mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2025-03-04 14:47:18 +00:00
refactor(element): rename riot role to element
Riot is now Element, and therefore this role has to do a lot of `s/riot/element/g`. There's still a few references to riot here and there, but fixing those depends on external changes. This does not attempt any automatic migration, you will need to clean up the old webroot or container yourself. BREAKING CHANGE: role name and variable names have changed
This commit is contained in:
parent
40510a6d02
commit
5a777cd2d1
23 changed files with 222 additions and 210 deletions
|
@ -4,7 +4,7 @@ services: docker
|
|||
|
||||
env:
|
||||
global:
|
||||
- ROLE_NAME: ansible-riot-webapp
|
||||
- ROLE_NAME: element
|
||||
matrix:
|
||||
- MOLECULE_DISTRO: debian9
|
||||
|
48
roles/element/README.md
Normal file
48
roles/element/README.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Element Web App
|
||||
|
||||
Dowloads, verifies and deploys the element web application and places into a
|
||||
webroot, or runs it as a container. Writes config files, with optional per
|
||||
domain configuration.
|
||||
|
||||
## Requirements
|
||||
|
||||
A webserver to serve the application is required if webroot installation mode is
|
||||
used, otherwise docker for running the container.
|
||||
|
||||
In case of the webroot installation mode, gpg and dirmngr are required for the
|
||||
package verification.
|
||||
|
||||
## Role Variables
|
||||
|
||||
See [defaults](defaults/main.yml) for optional variables. There are no mandatory
|
||||
variables.
|
||||
|
||||
## Dependencies
|
||||
|
||||
__None__
|
||||
|
||||
## Example Playbook
|
||||
|
||||
```yaml
|
||||
- hosts: servers
|
||||
tasks:
|
||||
- name: install gpg and dirmngr
|
||||
apt:
|
||||
state: present
|
||||
name:
|
||||
- gpg
|
||||
- dirmngr
|
||||
roles:
|
||||
- role: element
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
[madonius](https://github.com/madonius)
|
||||
[jcgruenhage](https://jcg.re)
|
62
roles/element/defaults/main.yml
Normal file
62
roles/element/defaults/main.yml
Normal file
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
element_version: 1.7.2
|
||||
element_webapp_dir: /opt/element
|
||||
element_config:
|
||||
default_server_config:
|
||||
m.homeserver:
|
||||
base_url: https://matrix-client.matrix.org
|
||||
server_name: matrix.org
|
||||
m.identity_server:
|
||||
base_url: https://vector.im
|
||||
disable_custom_urls: false
|
||||
disable_guests: false
|
||||
disable_login_language_selector: false
|
||||
disable_3pid_login: false
|
||||
brand: Element
|
||||
integrations_ui_url: https://scalar.vector.im/
|
||||
integrations_rest_url: https://scalar.vector.im/api
|
||||
integrations_widgets_urls:
|
||||
- https://scalar.vector.im/_matrix/integrations/v1
|
||||
- https://scalar.vector.im/api
|
||||
- https://scalar-staging.vector.im/_matrix/integrations/v1
|
||||
- https://scalar-staging.vector.im/api
|
||||
- https://scalar-staging.riot.im/scalar/api
|
||||
bug_report_endpoint_url: https://riot.im/bugreports/submit
|
||||
defaultCountryCode: GB
|
||||
showLabsSettings: false
|
||||
features:
|
||||
feature_new_spinner: labs
|
||||
feature_pinning: labs
|
||||
feature_custom_status: labs
|
||||
feature_custom_tags: labs
|
||||
feature_state_counters: labs
|
||||
default_federate: true
|
||||
default_theme: light
|
||||
roomDirectory:
|
||||
servers:
|
||||
- matrix.org
|
||||
welcomeUserId: "@riot-bot:matrix.org"
|
||||
piwik:
|
||||
url: https://piwik.riot.im/
|
||||
whitelistedHSUrls:
|
||||
- https://matrix.org
|
||||
whitelistedISUrls:
|
||||
- https://vector.im
|
||||
- https://matrix.org
|
||||
siteId: 1
|
||||
enable_presence_by_hs_url:
|
||||
https://matrix.org: false
|
||||
https://matrix-client.matrix.org: false
|
||||
settingDefaults:
|
||||
breadcrumbs: true
|
||||
jitsi:
|
||||
preferredDomain: jitsi.riot.im
|
||||
element_domain_configs: []
|
||||
element_deployment_method: 'webroot' #alternative is 'docker'
|
||||
element_docker_ports: []
|
||||
element_docker_labels: {}
|
||||
element_docker_volumes: "{{ element_docker_main_volumes + element_docker_domain_volumes }}"
|
||||
element_docker_main_volumes:
|
||||
- "{{ element_webapp_dir }}/config.json:/app/config.json"
|
||||
# This looks a bit crude, but what happens here is quite simple: First, we pull out the domain, then we match the whole string, and use it to construct the mount, then we make a list again.
|
||||
element_docker_domain_volumes: "{{ element_domain_configs | map(attribute='domain') | map('regex_replace', '^(.*)$', element_webapp_dir + '/config.\\1.json:/app/config.\\1.json') | list }}"
|
2
roles/element/handlers/main.yml
Normal file
2
roles/element/handlers/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# handlers file for element
|
|
@ -1,15 +1,12 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: Emmanouil Kampitakis (@madonius)
|
||||
description: Installs and configures a riot webapplication
|
||||
description: Installs and configures element
|
||||
|
||||
license: MIT
|
||||
|
||||
min_ansible_version: 2.7
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
|
@ -17,6 +14,6 @@ galaxy_info:
|
|||
|
||||
galaxy_tags:
|
||||
- matrix
|
||||
- riot
|
||||
- element
|
||||
|
||||
dependencies: []
|
|
@ -10,4 +10,4 @@
|
|||
- dirmngr
|
||||
become: true
|
||||
roles:
|
||||
- role: ansible-riot-webapp
|
||||
- role: element
|
57
roles/element/tasks/download.yml
Normal file
57
roles/element/tasks/download.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
- name: Check if element is already deployed
|
||||
stat:
|
||||
path: "{{ element_webapp_dir }}/element-v{{ element_version }}"
|
||||
register: element_app_directory
|
||||
|
||||
- name: Deploy element
|
||||
block:
|
||||
- name: Create gpg temporary home directory
|
||||
file:
|
||||
dest: /tmp/gpg-tmp
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
- name: Download element v{{ element_version }}
|
||||
get_url:
|
||||
url: "https://github.com/vector-im/element-web/releases/download/v{{ element_version }}/riot-v{{ element_version }}.tar.gz"
|
||||
dest: "/tmp/element-v{{ element_version }}.tar.gz"
|
||||
|
||||
- name: Download element v{{ element_version }} signature
|
||||
get_url:
|
||||
url: "https://github.com/vector-im/element-web/releases/download/v{{ element_version }}/riot-v{{ element_version }}.tar.gz.asc"
|
||||
dest: "/tmp/element-v{{ element_version }}.tar.gz.asc"
|
||||
|
||||
- name: Retrieve the Riot release key # noqa 301
|
||||
command: >-
|
||||
gpg --no-default-keyring
|
||||
--homedir /tmp/gpg-tmp
|
||||
--keyring /tmp/gpg-tmp/element-key
|
||||
--keyserver hkps://keyserver.ubuntu.com
|
||||
--recv-keys 5EA7E0F70461A3BCBEBE4D5EF6151806032026F9
|
||||
register: get_element_gpg_key
|
||||
until: get_element_gpg_key.rc == 0
|
||||
retries: 10
|
||||
delay: 2
|
||||
|
||||
- name: "Verify element v{{ element_version }}'s signature" # noqa 301
|
||||
command: >-
|
||||
gpg --no-default-keyring
|
||||
--homedir /tmp/gpg-tmp
|
||||
--keyring /tmp/gpg-tmp/element-key
|
||||
--verify /tmp/element-v{{ element_version }}.tar.gz.asc
|
||||
/tmp/element-v{{ element_version }}.tar.gz
|
||||
register: element_tarball_verification
|
||||
|
||||
- name: Unpack element
|
||||
unarchive:
|
||||
src: "/tmp/element-v{{ element_version }}.tar.gz"
|
||||
dest: "{{ element_webapp_dir }}"
|
||||
remote_src: yes
|
||||
when: element_tarball_verification.rc == 0
|
||||
|
||||
- name: Clean temporary gpg directory
|
||||
file:
|
||||
dest: /tmp/gpg-tmp
|
||||
state: absent
|
||||
when: not element_app_directory.stat.exists
|
45
roles/element/tasks/main.yml
Normal file
45
roles/element/tasks/main.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
- name: Create element directory
|
||||
file:
|
||||
dest: "{{ element_webapp_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Download and install element web app
|
||||
import_tasks: download.yml
|
||||
when: element_deployment_method == "webroot"
|
||||
|
||||
- name: Write main configuration
|
||||
copy:
|
||||
content: "{{ element_config | to_nice_json }}"
|
||||
dest: "{{ element_webapp_dir }}/config.json"
|
||||
|
||||
- name: Write domain specific configurations
|
||||
copy:
|
||||
content: "{{ item.config | to_nice_json }}"
|
||||
dest: "{{ element_webapp_dir }}/config.{{ item.domain }}.json"
|
||||
loop: "{{ element_domain_configs }}"
|
||||
|
||||
- name: Link main configuration
|
||||
file:
|
||||
src: "{{ element_webapp_dir }}/config.json"
|
||||
dest: "{{ element_webapp_dir }}/element-v{{ element_version }}/config.json"
|
||||
state: link
|
||||
when: element_deployment_method == "webroot"
|
||||
|
||||
- name: Link domain specific configurations
|
||||
file:
|
||||
src: "{{ element_webapp_dir }}/config.{{ item.domain }}.json"
|
||||
dest: "{{ element_webapp_dir }}/element-v{{ element_version }}/config.{{ item.domain }}.json"
|
||||
state: link
|
||||
loop: "{{ element_domain_configs }}"
|
||||
when: element_deployment_method == "webroot"
|
||||
|
||||
- name: Deploy docker container
|
||||
docker_container:
|
||||
name: "element-web"
|
||||
image: "docker.io/vectorim/riot-web:v{{ element_version }}"
|
||||
ports: "{{ element_docker_ports }}"
|
||||
labels: "{{ element_docker_labels_complete }}"
|
||||
restart_policy: unless-stopped
|
||||
volumes: "{{ element_docker_volumes }}"
|
||||
when: element_deployment_method == "docker"
|
4
roles/element/vars/main.yml
Normal file
4
roles/element/vars/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
element_docker_labels_complete: "{{ element_docker_labels_base | combine(element_docker_labels) }}"
|
||||
element_docker_labels_base:
|
||||
version: "{{ element_version }}"
|
|
@ -1 +0,0 @@
|
|||
* @jcgruenhage
|
|
@ -1,51 +0,0 @@
|
|||
# Riot Webapp
|
||||
|
||||
Dowloads, verifies and deploys the riot webapplication
|
||||
|
||||
## Requirements
|
||||
|
||||
A webserver to server the application is required.
|
||||
Additionally, gpg and dirmngr are required for the package verification
|
||||
|
||||
## Role Variables
|
||||
|
||||
### Mandatory Variables
|
||||
|
||||
__None__
|
||||
|
||||
### Optional Variables
|
||||
|
||||
| Name | Value | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| riot_webapp_dir | /opt/riot/ | location to upack the application |
|
||||
| riot_config | __See (defaults)[defaults/main.yml] | Dictionary containing the webapp configuration see (riot documentation)[https://github.com/vector-im/riot-web#configjson] for details
|
||||
|
||||
## Dependencies
|
||||
|
||||
__None__
|
||||
|
||||
## Example Playbook
|
||||
|
||||
```yaml
|
||||
- hosts: servers
|
||||
tasks:
|
||||
- name: install gpg and dirmngr
|
||||
apt:
|
||||
state: present
|
||||
name:
|
||||
- gpg
|
||||
- dirmngr
|
||||
roles:
|
||||
- role: ansible-riot-webapp
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
(madonius)[https://github.com/madonius]
|
||||
(jcgruenhage)[https://jcg.re]
|
|
@ -1,43 +0,0 @@
|
|||
---
|
||||
riot_version: 1.7.2
|
||||
riot_webapp_dir: /opt/riot
|
||||
riot_config:
|
||||
brand: Riot
|
||||
bug_report_endpoint_url: https://riot.im/bugreports/submit
|
||||
default_federate: true
|
||||
default_hs_url: https://matrix.org
|
||||
default_is_url: https://vector.im
|
||||
default_theme: light
|
||||
disable_3pid_login: false
|
||||
disable_custom_urls: false
|
||||
disable_guests: false
|
||||
disable_login_language_selector: false
|
||||
enable_presence_by_hs_url:
|
||||
'https://matrix.org': false
|
||||
features:
|
||||
feature_groups: labs
|
||||
feature_pinning: labs
|
||||
integrations_jitsi_widget_url: https://scalar.vector.im/api/widgets/jitsi.html
|
||||
integrations_rest_url: https://scalar.vector.im/api
|
||||
integrations_ui_url: https://scalar.vector.im/
|
||||
piwik:
|
||||
siteId: 1
|
||||
url: https://piwik.riot.im/
|
||||
whitelistedHSUrls:
|
||||
- 'https://matrix.org'
|
||||
whitelistedISUrls:
|
||||
- 'https://vector.im'
|
||||
- 'https://matrix.org'
|
||||
roomDirectory:
|
||||
servers:
|
||||
- matrix.org
|
||||
welcomeUserId: '@riot-bot:matrix.org'
|
||||
riot_domain_configs: []
|
||||
riot_deployment_method: 'webroot' #alternative is 'docker'
|
||||
riot_docker_ports: []
|
||||
riot_docker_labels: {}
|
||||
riot_docker_volumes: "{{ riot_docker_main_volumes + riot_docker_domain_volumes }}"
|
||||
riot_docker_main_volumes:
|
||||
- "{{ riot_webapp_dir }}/config.json:/app/config.json"
|
||||
# This looks a bit crude, but what happens here is quite simple: First, we pull out the domain, then we match the whole string, and use it to construct the mount, then we make a list again.
|
||||
riot_docker_domain_volumes: "{{ riot_domain_configs | map(attribute='domain') | map('regex_replace', '^(.*)$', riot_webapp_dir + '/config.\\1.json:/app/config.\\1.json') | list }}"
|
|
@ -1,2 +0,0 @@
|
|||
---
|
||||
# handlers file for ansible-riot-webapp
|
|
@ -1,57 +0,0 @@
|
|||
---
|
||||
- name: Check if riot is already deployed
|
||||
stat:
|
||||
path: "{{ riot_webapp_dir }}/riot-v{{ riot_version }}"
|
||||
register: riot_app_directory
|
||||
|
||||
- name: Deploy riot
|
||||
block:
|
||||
- name: Create gpg temporary home directory
|
||||
file:
|
||||
dest: /tmp/gpg-tmp
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
- name: Download riot v{{ riot_version }}
|
||||
get_url:
|
||||
url: "https://github.com/vector-im/riot-web/releases/download/v{{ riot_version }}/riot-v{{ riot_version }}.tar.gz"
|
||||
dest: "/tmp/riot-v{{ riot_version }}.tar.gz"
|
||||
|
||||
- name: Download riot v{{ riot_version }}
|
||||
get_url:
|
||||
url: "https://github.com/vector-im/riot-web/releases/download/v{{ riot_version }}/riot-v{{ riot_version }}.tar.gz.asc"
|
||||
dest: "/tmp/riot-v{{ riot_version }}.tar.gz.asc"
|
||||
|
||||
- name: Retrieve the Riot release key # noqa 301
|
||||
command: >-
|
||||
gpg --no-default-keyring
|
||||
--homedir /tmp/gpg-tmp
|
||||
--keyring /tmp/gpg-tmp/riot-key
|
||||
--keyserver hkps://keyserver.ubuntu.com
|
||||
--recv-keys 5EA7E0F70461A3BCBEBE4D5EF6151806032026F9
|
||||
register: get_riot_gpg_key
|
||||
until: get_riot_gpg_key.rc == 0
|
||||
retries: 10
|
||||
delay: 2
|
||||
|
||||
- name: "Verify riot v{{ riot_version }}'s signature" # noqa 301
|
||||
command: >-
|
||||
gpg --no-default-keyring
|
||||
--homedir /tmp/gpg-tmp
|
||||
--keyring /tmp/gpg-tmp/riot-key
|
||||
--verify /tmp/riot-v{{ riot_version }}.tar.gz.asc
|
||||
/tmp/riot-v{{ riot_version }}.tar.gz
|
||||
register: riot_tarball_verification
|
||||
|
||||
- name: Unpack riot
|
||||
unarchive:
|
||||
src: "/tmp/riot-v{{ riot_version }}.tar.gz"
|
||||
dest: "{{ riot_webapp_dir }}"
|
||||
remote_src: yes
|
||||
when: riot_tarball_verification.rc == 0
|
||||
|
||||
- name: Clean temporary gpg directory
|
||||
file:
|
||||
dest: /tmp/gpg-tmp
|
||||
state: absent
|
||||
when: not riot_app_directory.stat.exists
|
|
@ -1,45 +0,0 @@
|
|||
---
|
||||
- name: Create riot directory
|
||||
file:
|
||||
dest: "{{ riot_webapp_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Download and install riot web app
|
||||
import_tasks: download.yml
|
||||
when: riot_deployment_method == "webroot"
|
||||
|
||||
- name: Write main configuration
|
||||
copy:
|
||||
content: "{{ riot_config | to_nice_json }}"
|
||||
dest: "{{ riot_webapp_dir }}/config.json"
|
||||
|
||||
- name: Write domain specific configurations
|
||||
copy:
|
||||
content: "{{ item.config | to_nice_json }}"
|
||||
dest: "{{ riot_webapp_dir }}/config.{{ item.domain }}.json"
|
||||
loop: "{{ riot_domain_configs }}"
|
||||
|
||||
- name: Link main configuration
|
||||
file:
|
||||
src: "{{ riot_webapp_dir }}/config.json"
|
||||
dest: "{{ riot_webapp_dir }}/riot-v{{ riot_version }}/config.json"
|
||||
state: link
|
||||
when: riot_deployment_method == "webroot"
|
||||
|
||||
- name: Link domain specific configurations
|
||||
file:
|
||||
src: "{{ riot_webapp_dir }}/config.{{ item.domain }}.json"
|
||||
dest: "{{ riot_webapp_dir }}/riot-v{{ riot_version }}/config.{{ item.domain }}.json"
|
||||
state: link
|
||||
loop: "{{ riot_domain_configs }}"
|
||||
when: riot_deployment_method == "webroot"
|
||||
|
||||
- name: Deploy docker container
|
||||
docker_container:
|
||||
name: "riot-web"
|
||||
image: "docker.io/vectorim/riot-web:v{{ riot_version }}"
|
||||
ports: "{{ riot_docker_ports }}"
|
||||
labels: "{{ riot_docker_labels_complete }}"
|
||||
restart_policy: unless-stopped
|
||||
volumes: "{{ riot_docker_volumes }}"
|
||||
when: riot_deployment_method == "docker"
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
riot_docker_labels_complete: "{{ riot_docker_labels_base | combine(riot_docker_labels) }}"
|
||||
riot_docker_labels_base:
|
||||
version: "{{ riot_version }}"
|
Loading…
Add table
Reference in a new issue