Reload systemd services when they get updated

Fixes #69 (Github Issue)
This commit is contained in:
Slavi Pantaleev 2019-03-03 11:55:15 +02:00
parent 041a1947b3
commit 45618679f5
12 changed files with 139 additions and 2 deletions

View file

@ -34,18 +34,54 @@
src: "{{ role_path }}/templates/systemd/matrix-corporal.service.j2" src: "{{ role_path }}/templates/systemd/matrix-corporal.service.j2"
dest: "/etc/systemd/system/matrix-corporal.service" dest: "/etc/systemd/system/matrix-corporal.service"
mode: 0644 mode: 0644
register: matrix_corporal_systemd_service_result
when: "matrix_corporal_enabled" 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) # 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 - name: Ensure matrix-corporal files don't exist
file: file:
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
when: "not matrix_corporal_enabled"
with_items: with_items:
- /etc/systemd/system/matrix-corporal.service - /etc/systemd/system/matrix-corporal.service
- "{{ matrix_corporal_config_dir_path }}/config.json" - "{{ 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"

View file

@ -30,8 +30,14 @@
src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2" src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
dest: "/etc/systemd/system/matrix-coturn.service" dest: "/etc/systemd/system/matrix-coturn.service"
mode: 0644 mode: 0644
register: matrix_coturn_systemd_service_result
when: matrix_coturn_enabled 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 - name: Allow access to Coturn ports in firewalld
firewalld: firewalld:
port: "{{ item }}" port: "{{ item }}"
@ -67,6 +73,11 @@
state: absent state: absent
when: "not matrix_coturn_enabled and matrix_coturn_service_stat.stat.exists" 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 - name: Ensure Matrix coturn paths don't exist
file: file:
path: "{{ matrix_coturn_base_path }}" path: "{{ matrix_coturn_base_path }}"

View file

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

View file

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

View file

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

View file

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

View file

@ -44,8 +44,14 @@
src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2" src: "{{ role_path }}/templates/systemd/matrix-riot-web.service.j2"
dest: "/etc/systemd/system/matrix-riot-web.service" dest: "/etc/systemd/system/matrix-riot-web.service"
mode: 0644 mode: 0644
register: matrix_riot_web_systemd_service_result
when: matrix_riot_web_enabled 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) # Tasks related to getting rid of riot-web (if it was previously enabled)
# #
@ -69,6 +75,11 @@
state: absent state: absent
when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists" 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 - name: Ensure Matrix riot-web paths doesn't exist
file: file:
path: "{{ matrix_riot_web_data_path }}" path: "{{ matrix_riot_web_data_path }}"

View file

@ -35,8 +35,14 @@
src: "{{ role_path }}/templates/ext/appservice-irc/systemd/matrix-appservice-irc.service.j2" src: "{{ role_path }}/templates/ext/appservice-irc/systemd/matrix-appservice-irc.service.j2"
dest: "/etc/systemd/system/matrix-appservice-irc.service" dest: "/etc/systemd/system/matrix-appservice-irc.service"
mode: 0644 mode: 0644
register: matrix_appservice_irc_systemd_service_result
when: "matrix_appservice_irc_enabled" 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: - stat:
path: "{{ matrix_appservice_irc_base_path }}/registration.yaml" path: "{{ matrix_appservice_irc_base_path }}/registration.yaml"
register: appservice_irc_registration_file register: appservice_irc_registration_file

View file

@ -44,8 +44,14 @@
src: "{{ role_path }}/templates/ext/mautrix-telegram/systemd/matrix-mautrix-telegram.service.j2" src: "{{ role_path }}/templates/ext/mautrix-telegram/systemd/matrix-mautrix-telegram.service.j2"
dest: "/etc/systemd/system/matrix-mautrix-telegram.service" dest: "/etc/systemd/system/matrix-mautrix-telegram.service"
mode: 0644 mode: 0644
register: matrix_mautrix_telegram_systemd_service_result
when: "matrix_mautrix_telegram_enabled" 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 - name: Check if a mautrix-telegram registration file exists
stat: stat:
path: "{{ matrix_mautrix_telegram_base_path }}/registration.yaml" path: "{{ matrix_mautrix_telegram_base_path }}/registration.yaml"

View file

@ -33,8 +33,14 @@
src: "{{ role_path }}/templates/ext/mautrix-whatsapp/systemd/matrix-mautrix-whatsapp.service.j2" src: "{{ role_path }}/templates/ext/mautrix-whatsapp/systemd/matrix-mautrix-whatsapp.service.j2"
dest: "/etc/systemd/system/matrix-mautrix-whatsapp.service" dest: "/etc/systemd/system/matrix-mautrix-whatsapp.service"
mode: 0644 mode: 0644
register: matrix_mautrix_whatsapp_systemd_service_result
when: "matrix_mautrix_whatsapp_enabled" 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 - name: Check if a mautrix-whatsapp registration file exists
stat: stat:
path: "{{ matrix_mautrix_whatsapp_base_path }}/registration.yaml" path: "{{ matrix_mautrix_whatsapp_base_path }}/registration.yaml"

View file

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

View file

@ -64,6 +64,12 @@
src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2" src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
dest: "/etc/systemd/system/matrix-synapse.service" dest: "/etc/systemd/system/matrix-synapse.service"
mode: 0644 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 - name: Ensure matrix-synapse-register-user script created
template: template: