matrix-docker-ansible-deploy/roles/matrix-riot-web/tasks/setup_riot_web.yml

128 lines
4.5 KiB
YAML
Raw Normal View History

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