Reload systemd services when they get updated

Fixes #69 (Github Issue)
master
Slavi Pantaleev 5 years ago
parent 041a1947b3
commit 45618679f5

@ -34,18 +34,54 @@
src: "{{ role_path }}/templates/systemd/matrix-corporal.service.j2"
dest: "/etc/systemd/system/matrix-corporal.service"
mode: 0644
register: matrix_corporal_systemd_service_result
when: "matrix_corporal_enabled"
- name: Ensure systemd reloaded after matrix-corporal.service installation
service:
daemon_reload: yes
when: "matrix_corporal_enabled and matrix_corporal_systemd_service_result.changed"
#
# Tasks related to getting rid of matrix-corporal (if it was previously enabled)
#
- name: Check existence of matrix-corporal service
stat:
path: "/etc/systemd/system/matrix-corporal.service"
register: matrix_corporal_service_stat
- name: Ensure matrix-corporal is stopped
service:
name: matrix-corporal
state: stopped
daemon_reload: yes
register: stopping_result
when: "not matrix_corporal_enabled and matrix_corporal_service_stat.stat.exists"
- name: Ensure matrix-corporal.service doesn't exist
file:
path: "/etc/systemd/system/matrix-corporal.service"
state: absent
when: "not matrix_corporal_enabled and matrix_corporal_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-corporal.service removal
service:
daemon_reload: yes
when: "not matrix_corporal_enabled and matrix_corporal_service_stat.stat.exists"
- name: Ensure matrix-corporal files don't exist
file:
path: "{{ item }}"
state: absent
when: "not matrix_corporal_enabled"
with_items:
- /etc/systemd/system/matrix-corporal.service
- "{{ matrix_corporal_config_dir_path }}/config.json"
when: "not matrix_corporal_enabled"
- name: Ensure Matrix Corporal Docker image doesn't exist
docker_image:
name: "{{ matrix_corporal_docker_image }}"
state: absent
when: "not matrix_corporal_enabled"

@ -30,8 +30,14 @@
src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
dest: "/etc/systemd/system/matrix-coturn.service"
mode: 0644
register: matrix_coturn_systemd_service_result
when: matrix_coturn_enabled
- name: Ensure systemd reloaded after matrix-coturn.service installation
service:
daemon_reload: yes
when: "matrix_coturn_enabled and matrix_coturn_systemd_service_result.changed"
- name: Allow access to Coturn ports in firewalld
firewalld:
port: "{{ item }}"
@ -67,6 +73,11 @@
state: absent
when: "not matrix_coturn_enabled and matrix_coturn_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-coturn.service removal
service:
daemon_reload: yes
when: "not matrix_coturn_enabled and matrix_coturn_service_stat.stat.exists"
- name: Ensure Matrix coturn paths don't exist
file:
path: "{{ matrix_coturn_base_path }}"
@ -77,4 +88,4 @@
docker_image:
name: "{{ matrix_coturn_docker_image }}"
state: absent
when: "not matrix_coturn_enabled"
when: "not matrix_coturn_enabled"

@ -30,8 +30,14 @@
src: "{{ role_path }}/templates/systemd/matrix-mailer.service.j2"
dest: "/etc/systemd/system/matrix-mailer.service"
mode: 0644
register: matrix_mailer_systemd_service_result
when: matrix_mailer_enabled
- name: Ensure systemd reloaded after matrix-mailer.service installation
service:
daemon_reload: yes
when: "matrix_mailer_enabled and matrix_mailer_systemd_service_result.changed"
#
# Tasks related to getting rid of the mailer (if it was previously enabled)
#
@ -55,6 +61,11 @@
state: absent
when: "not matrix_mailer_enabled and matrix_mailer_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-mailer.service removal
service:
daemon_reload: yes
when: "not matrix_mailer_enabled and matrix_mailer_service_stat.stat.exists"
- name: Ensure Matrix mailer environment variables path doesn't exist
file:
path: "{{ matrix_mailer_base_path }}"

@ -35,8 +35,14 @@
src: "{{ role_path }}/templates/systemd/matrix-mxisd.service.j2"
dest: "/etc/systemd/system/matrix-mxisd.service"
mode: 0644
register: matrix_mxisd_systemd_service_result
when: matrix_mxisd_enabled
- name: Ensure systemd reloaded after matrix-mxisd.service installation
service:
daemon_reload: yes
when: "matrix_mxisd_enabled and matrix_mxisd_systemd_service_result.changed"
#
# Tasks related to getting rid of mxisd (if it was previously enabled)
#
@ -60,6 +66,11 @@
state: absent
when: "not matrix_mxisd_enabled and matrix_mxisd_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-mxisd.service removal
service:
daemon_reload: yes
when: "not matrix_mxisd_enabled and matrix_mxisd_service_stat.stat.exists"
- name: Ensure Matrix mxisd paths don't exist
file:
path: "{{ matrix_mxisd_base_path }}"

@ -90,8 +90,14 @@
src: "{{ role_path }}/templates/systemd/matrix-nginx-proxy.service.j2"
dest: "/etc/systemd/system/matrix-nginx-proxy.service"
mode: 0644
register: matrix_nginx_proxy_systemd_service_result
when: matrix_nginx_proxy_enabled
- name: Ensure systemd reloaded after matrix-nginx-proxy.service installation
service:
daemon_reload: yes
when: "matrix_nginx_proxy_enabled and matrix_nginx_proxy_systemd_service_result.changed"
#
# Tasks related to getting rid of matrix-nginx-proxy (if it was previously enabled)
@ -116,6 +122,11 @@
state: absent
when: "not matrix_nginx_proxy_enabled and matrix_nginx_proxy_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-nginx-proxy.service removal
service:
daemon_reload: yes
when: "not matrix_nginx_proxy_enabled and matrix_nginx_proxy_service_stat.stat.exists"
- name: Ensure Matrix nginx-proxy configuration for matrix domain deleted
file:
path: "{{ matrix_nginx_proxy_confd_path }}/matrix-synapse.conf"

@ -76,8 +76,14 @@
src: "{{ role_path }}/templates/systemd/matrix-postgres.service.j2"
dest: "/etc/systemd/system/matrix-postgres.service"
mode: 0644
register: matrix_postgres_systemd_service_result
when: matrix_postgres_enabled
- name: Ensure systemd reloaded after matrix-postgres.service installation
service:
daemon_reload: yes
when: "matrix_postgres_enabled and matrix_postgres_systemd_service_result.changed"
#
# Tasks related to getting rid of the internal postgres server (if it was previously enabled)
#
@ -101,6 +107,11 @@
state: absent
when: "not matrix_postgres_enabled and matrix_postgres_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-postgres.service removal
service:
daemon_reload: yes
when: "not matrix_postgres_enabled and matrix_postgres_service_stat.stat.exists"
- name: Check existence of matrix-postgres local data path
stat:
path: "{{ matrix_postgres_data_path }}"

@ -44,8 +44,14 @@
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
- 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)
#
@ -69,6 +75,11 @@
state: absent
when: "not matrix_riot_web_enabled 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 and matrix_riot_web_service_stat.stat.exists"
- name: Ensure Matrix riot-web paths doesn't exist
file:
path: "{{ matrix_riot_web_data_path }}"

@ -35,8 +35,14 @@
src: "{{ role_path }}/templates/ext/appservice-irc/systemd/matrix-appservice-irc.service.j2"
dest: "/etc/systemd/system/matrix-appservice-irc.service"
mode: 0644
register: matrix_appservice_irc_systemd_service_result
when: "matrix_appservice_irc_enabled"
- name: Ensure systemd reloaded after matrix-appservice-irc.service installation
service:
daemon_reload: yes
when: "matrix_appservice_irc_enabled and matrix_appservice_irc_systemd_service_result.changed"
- stat:
path: "{{ matrix_appservice_irc_base_path }}/registration.yaml"
register: appservice_irc_registration_file

@ -44,8 +44,14 @@
src: "{{ role_path }}/templates/ext/mautrix-telegram/systemd/matrix-mautrix-telegram.service.j2"
dest: "/etc/systemd/system/matrix-mautrix-telegram.service"
mode: 0644
register: matrix_mautrix_telegram_systemd_service_result
when: "matrix_mautrix_telegram_enabled"
- name: Ensure systemd reloaded after matrix-mautrix-telegram.service installation
service:
daemon_reload: yes
when: "matrix_mautrix_telegram_enabled and matrix_mautrix_telegram_systemd_service_result.changed"
- name: Check if a mautrix-telegram registration file exists
stat:
path: "{{ matrix_mautrix_telegram_base_path }}/registration.yaml"

@ -33,8 +33,14 @@
src: "{{ role_path }}/templates/ext/mautrix-whatsapp/systemd/matrix-mautrix-whatsapp.service.j2"
dest: "/etc/systemd/system/matrix-mautrix-whatsapp.service"
mode: 0644
register: matrix_mautrix_whatsapp_systemd_service_result
when: "matrix_mautrix_whatsapp_enabled"
- name: Ensure systemd reloaded after matrix-mautrix-whatsapp.service installation
service:
daemon_reload: yes
when: "matrix_mautrix_whatsapp_enabled and matrix_mautrix_whatsapp_systemd_service_result.changed"
- name: Check if a mautrix-whatsapp registration file exists
stat:
path: "{{ matrix_mautrix_whatsapp_base_path }}/registration.yaml"

@ -37,8 +37,14 @@
src: "{{ role_path }}/templates/goofys/systemd/matrix-goofys.service.j2"
dest: "/etc/systemd/system/matrix-goofys.service"
mode: 0644
register: matrix_goofys_systemd_service_result
when: matrix_s3_media_store_enabled
- name: Ensure systemd reloaded after matrix-goofys.service installation
service:
daemon_reload: yes
when: "matrix_s3_media_store_enabled and matrix_goofys_systemd_service_result.changed"
#
# Tasks related to getting rid of goofys (if it was previously enabled)
#
@ -62,6 +68,11 @@
state: absent
when: "not matrix_s3_media_store_enabled and matrix_goofys_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-goofys.service removal
service:
daemon_reload: yes
when: "not matrix_s3_media_store_enabled and matrix_goofys_service_stat.stat.exists"
- name: Ensure goofys environment variables file doesn't exist
file:
path: "{{ matrix_synapse_config_dir_path }}/env-goofys"

@ -64,6 +64,12 @@
src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
dest: "/etc/systemd/system/matrix-synapse.service"
mode: 0644
register: matrix_synapse_systemd_service_result
- name: Ensure systemd reloaded after matrix-synapse.service installation
service:
daemon_reload: yes
when: matrix_synapse_systemd_service_result.changed
- name: Ensure matrix-synapse-register-user script created
template:

Loading…
Cancel
Save