Optimize uninstall tasks a bit

- forego removing Docker images - it's not effective anyway, because it
  only removes the last version.. which is a drop in the bucket, usually

- do not reload systemd - it's none of our business. `--tags=start`,
  etc., handle this

- combine all uninstall tasks under a single block, which only runs if
  we detect traces (a leftover systemd .service file) of the component.
  If no such .service is detected, we skip them all. This may lead to
  incorect cleanup in rare cases, but is good enough for the most part.
This commit is contained in:
Slavi Pantaleev
2022-11-25 17:17:54 +02:00
parent 8456657f21
commit a04f6f4e3d
66 changed files with 733 additions and 1208 deletions

View File

@ -6,42 +6,33 @@
register: matrix_coturn_service_stat
when: "not matrix_coturn_enabled | bool"
- name: Ensure matrix-coturn is stopped
ansible.builtin.service:
name: matrix-coturn
state: stopped
enabled: false
daemon_reload: true
when: "matrix_coturn_service_stat.stat.exists | bool"
- when: matrix_coturn_service_stat.stat.exists | bool
block:
- name: Ensure matrix-coturn is stopped
ansible.builtin.service:
name: matrix-coturn
state: stopped
enabled: false
daemon_reload: true
- name: Ensure matrix-coturn-reload.timer is stopped
ansible.builtin.service:
name: matrix-coturn
state: stopped
enabled: false
daemon_reload: true
failed_when: false
when: "matrix_coturn_service_stat.stat.exists | bool"
- name: Ensure matrix-coturn-reload.timer is stopped
ansible.builtin.service:
name: matrix-coturn
state: stopped
enabled: false
daemon_reload: true
failed_when: false
- name: Ensure systemd units don't exist
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/{{ item }}"
state: absent
register: matrix_coturn_systemd_unit_uninstallation_result
with_items:
- matrix-coturn.service
- matrix-coturn-reload.service
- matrix-coturn-reload.timer
- name: Ensure systemd units don't exist
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/{{ item }}"
state: absent
with_items:
- matrix-coturn.service
- matrix-coturn-reload.service
- matrix-coturn-reload.timer
- name: Ensure systemd reloaded after unit removal
ansible.builtin.service:
daemon_reload: true
when: "matrix_coturn_systemd_unit_uninstallation_result.changed | bool"
- name: Ensure Matrix coturn paths don't exist
ansible.builtin.file:
path: "{{ matrix_coturn_base_path }}"
state: absent
# Intentionally not removing the Docker image when uninstalling.
# We can't be sure it had been pulled by us in the first place.
- name: Ensure Matrix coturn paths don't exist
ansible.builtin.file:
path: "{{ matrix_coturn_base_path }}"
state: absent