Просмотр исходного кода

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

Fixes https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/2211
pull/2212/head
Slavi Pantaleev 3 лет назад
Родитель
Сommit
7fb45a507d
4 измененных файлов: 22 добавлений и 9 удалений
  1. +5
    -0
      group_vars/matrix_servers
  2. +4
    -0
      roles/matrix-postgres/defaults/main.yml
  3. +6
    -5
      roles/matrix-postgres/tasks/run_vacuum.yml
  4. +7
    -4
      roles/matrix-postgres/tasks/upgrade_postgres.yml

+ 5
- 0
group_vars/matrix_servers Просмотреть файл

@@ -2112,6 +2112,11 @@ matrix_postgres_additional_databases: |

}}

matrix_postgres_systemd_services_to_stop_for_maintenance_list: |
{{
['matrix-' + matrix_homeserver_implementation + '.service']
}}

######################################################################
#
# /matrix-postgres


+ 4
- 0
roles/matrix-postgres/defaults/main.yml Просмотреть файл

@@ -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.


+ 6
- 5
roles/matrix-postgres/tasks/run_vacuum.yml Просмотреть файл

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

+ 7
- 4
roles/matrix-postgres/tasks/upgrade_postgres.yml Просмотреть файл

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

Загрузка…
Отмена
Сохранить