Make --tags=run-postgres-vacuum and --tags=upgrade-postgres not assume Synapse

Fixes https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/2211
This commit is contained in:
Slavi Pantaleev 2022-10-28 17:39:53 +03:00
parent 5084aa0c65
commit 7fb45a507d
4 changed files with 22 additions and 9 deletions

View file

@ -2112,6 +2112,11 @@ matrix_postgres_additional_databases: |
}}
matrix_postgres_systemd_services_to_stop_for_maintenance_list: |
{{
['matrix-' + matrix_homeserver_implementation + '.service']
}}
######################################################################
#
# /matrix-postgres

View file

@ -15,6 +15,10 @@ matrix_postgres_db_name: "matrix"
matrix_postgres_base_path: "{{ matrix_base_data_path }}/postgres"
matrix_postgres_data_path: "{{ matrix_postgres_base_path }}/data"
# matrix_postgres_systemd_services_to_stop_for_maintenance_list specifies the list of systemd services to stop before vacuuming or upgrading.
# These services will be restarted after the operation completes.
matrix_postgres_systemd_services_to_stop_for_maintenance_list: []
matrix_postgres_architecture: amd64
# matrix_postgres_docker_image_suffix controls whether we use Alpine-based images (`-alpine`) or the normal Debian-based images.

View file

@ -67,11 +67,12 @@
- ansible.builtin.set_fact:
matrix_postgres_synapse_was_running: "{{ ansible_facts.services['matrix-synapse.service'] | default(none) is not none and ansible_facts.services['matrix-synapse.service'].state == 'running' }}"
- name: Ensure matrix-synapse is stopped
- name: Ensure services are stopped
ansible.builtin.service:
name: matrix-synapse
name: "{{ item }}"
state: stopped
daemon_reload: true
with_items: "{{ matrix_postgres_systemd_services_to_stop_for_maintenance_list }}"
- name: Run Postgres vacuum command
ansible.builtin.command: "{{ matrix_postgres_vacuum_command }}"
@ -85,9 +86,9 @@
- ansible.builtin.debug:
var: "matrix_postgres_synapse_vacuum_result"
- name: Ensure matrix-synapse is started, if it previously was
- name: Ensure services are started
ansible.builtin.service:
name: matrix-synapse
name: "{{ item }}"
state: started
daemon_reload: true
when: "matrix_postgres_synapse_was_running | bool"
with_items: "{{ matrix_postgres_systemd_services_to_stop_for_maintenance_list }}"

View file

@ -55,10 +55,12 @@
- ansible.builtin.debug:
msg: "Upgrading database from {{ matrix_postgres_detected_version_corresponding_docker_image }} to {{ matrix_postgres_docker_image_latest }}"
- name: Ensure matrix-synapse is stopped
- name: Ensure services are stopped
ansible.builtin.service:
name: matrix-synapse
name: "{{ item }}"
state: stopped
daemon_reload: true
with_items: "{{ matrix_postgres_systemd_services_to_stop_for_maintenance_list }}"
- name: Ensure matrix-postgres is started
ansible.builtin.service:
@ -175,11 +177,12 @@
path: "{{ postgres_dump_dir }}/{{ postgres_dump_name }}"
state: absent
- name: Ensure matrix-synapse is started
- name: Ensure services are started
ansible.builtin.service:
name: matrix-synapse
name: "{{ item }}"
state: started
daemon_reload: true
with_items: "{{ matrix_postgres_systemd_services_to_stop_for_maintenance_list }}"
- ansible.builtin.debug:
msg: "NOTE: Your old Postgres data directory is preserved at `{{ postgres_auto_upgrade_backup_data_path }}`. You might want to get rid of it once you've confirmed that all is well."