2022-02-05 20:32:54 +00:00
---
2022-07-18 07:39:08 +00:00
- ansible.builtin.debug :
2020-08-21 10:52:16 +00:00
msg : "Compressing room `{{ room_details.room_id }}` having {{ room_details.count }} state group rows"
- name : Generate rust-synapse-compress-state room compression command
2022-07-18 07:39:08 +00:00
ansible.builtin.set_fact :
2020-08-21 10:52:16 +00:00
matrix_synapse_rust_synapse_compress_state_compress_room_command : >-
2022-11-04 14:39:35 +00:00
{{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-compress-room
2023-02-17 15:16:50 +00:00
--user={{ matrix_synapse_uid }}:{{ matrix_synapse_gid }}
2020-08-21 10:52:16 +00:00
--cap-drop=ALL
--network={{ matrix_docker_network }}
2020-11-25 08:49:59 +00:00
--mount type=bind,src={{ matrix_synapse_rust_synapse_compress_state_base_path }},dst=/work
2020-08-21 10:52:16 +00:00
{{ matrix_synapse_rust_synapse_compress_state_docker_image }}
2022-03-26 08:04:21 +00:00
{{ matrix_synapse_rust_synapse_compress_state_synapse_compress_state_in_container_path }} -t -o /work/state-compressor.sql
2020-08-21 10:52:16 +00:00
-p "host={{ matrix_synapse_database_host }} user={{ matrix_synapse_database_user }} password={{ matrix_synapse_database_password }} dbname={{ matrix_synapse_database_database }}"
-r '{{ room_details.room_id }}'
- name : Run rust-synapse-compress-state room compression command (SQL generation)
2022-07-18 07:39:08 +00:00
ansible.builtin.command : "{{ matrix_synapse_rust_synapse_compress_state_compress_room_command }}"
2020-08-21 10:52:16 +00:00
async : "{{ matrix_synapse_rust_synapse_compress_state_compress_room_time }}"
poll : 10
register : matrix_synapse_rust_synapse_compress_state_compress_room_command_result
2022-11-01 12:57:29 +00:00
failed_when : not matrix_synapse_rust_synapse_compress_state_compress_room_command_result.finished or matrix_synapse_rust_synapse_compress_state_compress_room_command_result.rc != 0
2022-10-06 16:48:11 +00:00
changed_when : matrix_synapse_rust_synapse_compress_state_compress_room_command_result.finished and matrix_synapse_rust_synapse_compress_state_compress_room_command_result.rc == 0
2020-08-21 10:52:16 +00:00
2022-10-25 03:43:57 +00:00
- ansible.builtin.debug :
var : "matrix_synapse_rust_synapse_compress_state_compress_room_command_result"
2020-08-21 10:52:16 +00:00
- name : Generate Postgres compression SQL import command
2022-07-18 07:39:08 +00:00
ansible.builtin.set_fact :
2020-08-21 10:52:16 +00:00
matrix_synapse_rust_synapse_compress_state_psql_import_command : >-
2022-11-04 14:39:35 +00:00
{{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-rust-synapse-compress-state-psql-import
2022-11-27 05:23:41 +00:00
--user={{ devture_postgres_uid }}:{{ devture_postgres_gid }}
2020-08-21 10:52:16 +00:00
--cap-drop=ALL
2022-11-27 05:23:41 +00:00
--network={{ devture_postgres_container_network }}
--env-file={{ devture_postgres_base_path }}/env-postgres-psql
2020-11-25 08:49:59 +00:00
--mount type=bind,src={{ matrix_synapse_rust_synapse_compress_state_base_path }},dst=/work,ro
2020-08-21 10:52:16 +00:00
--entrypoint=/bin/sh
2022-11-27 05:23:41 +00:00
{{ devture_postgres_container_image_latest }}
2020-08-21 10:52:16 +00:00
-c "cat /work/state-compressor.sql |
2022-11-27 06:31:54 +00:00
psql -v ON_ERROR_STOP=1 -h {{ devture_postgres_connection_hostname }} -d {{ matrix_synapse_database_database }}"
2020-08-21 10:52:16 +00:00
- name : Import compression SQL into Postgres
2022-07-18 07:39:08 +00:00
ansible.builtin.command : "{{ matrix_synapse_rust_synapse_compress_state_psql_import_command }}"
2020-08-21 10:52:16 +00:00
async : "{{ matrix_synapse_rust_synapse_compress_state_psql_import_time }}"
poll : 10
register : matrix_synapse_rust_synapse_compress_state_psql_import_command_result
2022-10-06 16:48:11 +00:00
failed_when : not matrix_synapse_rust_synapse_compress_state_psql_import_command_result.finished
changed_when : matrix_synapse_rust_synapse_compress_state_psql_import_command_result.finished and matrix_synapse_rust_synapse_compress_state_psql_import_command_result.rc == 0
2020-08-21 10:52:16 +00:00
- name : Clean up
2022-07-18 07:39:08 +00:00
ansible.builtin.file :
2020-08-21 10:52:16 +00:00
path : "{{ matrix_synapse_rust_synapse_compress_state_base_path }}/state-compressor.sql"
state : absent