2017-07-31 22:07:30 +02:00
|
|
|
---
|
|
|
|
|
2017-09-12 11:41:44 +02:00
|
|
|
#
|
|
|
|
# Tasks related to setting up riot-web
|
|
|
|
#
|
|
|
|
|
2018-08-07 14:08:46 +02:00
|
|
|
- name: Ensure Matrix riot-web path exists
|
2017-07-31 22:07:30 +02:00
|
|
|
file:
|
2020-03-18 17:24:03 +01:00
|
|
|
path: "{{ item.path }}"
|
2017-07-31 22:07:30 +02:00
|
|
|
state: directory
|
|
|
|
mode: 0750
|
|
|
|
owner: "{{ matrix_user_username }}"
|
|
|
|
group: "{{ matrix_user_username }}"
|
2020-03-08 00:24:00 +01:00
|
|
|
with_items:
|
2020-03-18 17:24:03 +01:00
|
|
|
- { path: "{{ matrix_riot_web_data_path }}", when: true }
|
|
|
|
- { path: "{{ matrix_riot_web_docker_src_files_path }}", when: "{{ matrix_riot_web_container_image_self_build }}" }
|
|
|
|
when: matrix_riot_web_enabled|bool and item.when
|
2017-07-31 22:07:30 +02:00
|
|
|
|
|
|
|
- name: Ensure riot-web Docker image is pulled
|
|
|
|
docker_image:
|
2018-11-01 07:46:47 +01:00
|
|
|
name: "{{ matrix_riot_web_docker_image }}"
|
2019-05-22 12:43:33 +02:00
|
|
|
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
2019-06-10 13:23:51 +02:00
|
|
|
force_source: "{{ matrix_riot_web_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
|
|
|
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_riot_web_docker_image_force_pull }}"
|
2020-03-15 09:15:27 +01:00
|
|
|
when: matrix_riot_web_enabled|bool and not matrix_riot_web_container_image_self_build
|
2020-02-21 18:51:56 +01:00
|
|
|
|
2020-03-08 00:24:00 +01:00
|
|
|
- name: Ensure Riot Web repository is present on self-build
|
2020-02-21 18:51:56 +01:00
|
|
|
git:
|
|
|
|
repo: https://github.com/vector-im/riot-web.git
|
2020-03-08 00:28:14 +01:00
|
|
|
dest: "{{ matrix_riot_web_docker_src_files_path }}"
|
2020-03-14 19:54:13 +01:00
|
|
|
version: "{{ matrix_riot_web_docker_image.split(':')[1] }}"
|
2020-02-21 18:51:56 +01:00
|
|
|
force: "yes"
|
2020-03-15 09:15:27 +01:00
|
|
|
when: "matrix_riot_web_enabled|bool and matrix_riot_web_container_image_self_build"
|
2020-02-21 18:51:56 +01:00
|
|
|
|
2020-03-15 10:34:35 +01:00
|
|
|
- name: Ensure Riot Web Docker image is built
|
2020-02-21 18:51:56 +01:00
|
|
|
docker_image:
|
|
|
|
name: "{{ matrix_riot_web_docker_image }}"
|
|
|
|
source: build
|
|
|
|
build:
|
|
|
|
dockerfile: Dockerfile
|
2020-03-08 00:28:14 +01:00
|
|
|
path: "{{ matrix_riot_web_docker_src_files_path }}"
|
2020-02-21 18:51:56 +01:00
|
|
|
pull: yes
|
2020-03-15 09:15:27 +01:00
|
|
|
when: "matrix_riot_web_enabled|bool and matrix_riot_web_container_image_self_build"
|
2017-07-31 22:07:30 +02:00
|
|
|
|
2019-08-25 09:37:05 +02:00
|
|
|
- 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 }}"
|
2019-08-25 09:44:01 +02:00
|
|
|
when: matrix_riot_web_enabled|bool
|
2019-08-25 09:37:05 +02:00
|
|
|
|
2019-02-16 10:48:17 +01:00
|
|
|
- name: Ensure Matrix riot-web config files installed
|
2017-07-31 22:07:30 +02:00
|
|
|
template:
|
2018-12-11 14:48:54 +01:00
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
|
2017-07-31 22:07:30 +02:00
|
|
|
mode: 0644
|
|
|
|
owner: "{{ matrix_user_username }}"
|
|
|
|
group: "{{ matrix_user_username }}"
|
|
|
|
with_items:
|
2019-01-27 19:25:13 +01:00
|
|
|
- {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
|
2019-04-25 01:05:28 +02:00
|
|
|
- {src: "{{ role_path }}/templates/welcome.html.j2", name: "welcome.html"}
|
2019-02-16 10:48:17 +01:00
|
|
|
- {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "matrix_riot_web_enabled|bool and item.src is not none"
|
2019-02-16 10:48:17 +01:00
|
|
|
|
|
|
|
- name: Ensure Matrix riot-web config files removed
|
|
|
|
file:
|
|
|
|
path: "{{ matrix_riot_web_data_path }}/{{ item.name }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- {src: "{{ matrix_riot_web_embedded_pages_home_path }}", name: "home.html"}
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "matrix_riot_web_enabled|bool and item.src is none"
|
2017-07-31 22:07:30 +02:00
|
|
|
|
|
|
|
- name: Ensure matrix-riot-web.service installed
|
|
|
|
template:
|
|
|
|
src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2"
|
2020-03-24 19:27:58 +01:00
|
|
|
dest: "{{ matrix_systemd_path }}/matrix-riot-web.service"
|
2017-09-12 11:41:44 +02:00
|
|
|
mode: 0644
|
2019-03-03 10:55:15 +01:00
|
|
|
register: matrix_riot_web_systemd_service_result
|
2019-05-21 17:25:59 +02:00
|
|
|
when: matrix_riot_web_enabled|bool
|
2017-09-12 11:41:44 +02:00
|
|
|
|
2019-03-03 10:55:15 +01:00
|
|
|
- name: Ensure systemd reloaded after matrix-riot-web.service installation
|
|
|
|
service:
|
|
|
|
daemon_reload: yes
|
|
|
|
when: "matrix_riot_web_enabled and matrix_riot_web_systemd_service_result.changed"
|
|
|
|
|
2017-09-12 11:41:44 +02:00
|
|
|
#
|
|
|
|
# Tasks related to getting rid of riot-web (if it was previously enabled)
|
|
|
|
#
|
|
|
|
|
|
|
|
- name: Check existence of matrix-riot-web service
|
2019-01-07 23:35:35 +01:00
|
|
|
stat:
|
2020-03-24 19:27:58 +01:00
|
|
|
path: "{{ matrix_systemd_path }}/matrix-riot-web.service"
|
2017-09-12 11:41:44 +02:00
|
|
|
register: matrix_riot_web_service_stat
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool"
|
2017-09-12 11:41:44 +02:00
|
|
|
|
|
|
|
- name: Ensure matrix-riot-web is stopped
|
2019-01-07 23:35:35 +01:00
|
|
|
service:
|
|
|
|
name: matrix-riot-web
|
|
|
|
state: stopped
|
|
|
|
daemon_reload: yes
|
2017-09-12 11:41:44 +02:00
|
|
|
register: stopping_result
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
|
2017-09-12 11:41:44 +02:00
|
|
|
|
|
|
|
- name: Ensure matrix-riot-web.service doesn't exist
|
|
|
|
file:
|
2020-03-24 19:27:58 +01:00
|
|
|
path: "{{ matrix_systemd_path }}/matrix-riot-web.service"
|
2017-09-12 11:41:44 +02:00
|
|
|
state: absent
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
|
2017-09-12 11:41:44 +02:00
|
|
|
|
2019-03-03 10:55:15 +01:00
|
|
|
- name: Ensure systemd reloaded after matrix-riot-web.service removal
|
|
|
|
service:
|
|
|
|
daemon_reload: yes
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool and matrix_riot_web_service_stat.stat.exists"
|
2019-03-03 10:55:15 +01:00
|
|
|
|
2017-09-12 11:41:44 +02:00
|
|
|
- name: Ensure Matrix riot-web paths doesn't exist
|
|
|
|
file:
|
2018-09-17 07:24:35 +02:00
|
|
|
path: "{{ matrix_riot_web_data_path }}"
|
2017-09-12 11:41:44 +02:00
|
|
|
state: absent
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool"
|
2017-09-12 11:41:44 +02:00
|
|
|
|
|
|
|
- name: Ensure riot-web Docker image doesn't exist
|
|
|
|
docker_image:
|
2018-11-01 07:46:47 +01:00
|
|
|
name: "{{ matrix_riot_web_docker_image }}"
|
2017-09-12 11:41:44 +02:00
|
|
|
state: absent
|
2019-05-21 17:25:59 +02:00
|
|
|
when: "not matrix_riot_web_enabled|bool"
|