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"
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"