From 300fc1d40fc59bb9b0b771e18e40ab77ea0a3402 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 23 Oct 2025 08:38:20 +0000 Subject: [PATCH] Update 2 files - /roles/matrix/files/homeserver.yaml - /roles/matrix/tasks/main.yml --- roles/matrix/files/homeserver.yaml | 5 +++-- roles/matrix/tasks/main.yml | 34 ++++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/roles/matrix/files/homeserver.yaml b/roles/matrix/files/homeserver.yaml index a68ef0b..65b543f 100644 --- a/roles/matrix/files/homeserver.yaml +++ b/roles/matrix/files/homeserver.yaml @@ -1,6 +1,7 @@ server_name: "{{ matrix_server_name }}" pid_file: /data/homeserver.pid public_baseurl: "https://{{ matrix_domain }}/" + listeners: - port: 8008 tls: false @@ -23,13 +24,13 @@ database: log_config: "/data/log.config" media_store_path: /data/media_store uploads_path: /data/uploads -enable_registration: {{ matrix_registration_enabled }} +enable_registration: {{ matrix_registration_enabled | bool | lower }} enable_registration_without_verification: false registration_shared_secret: "{{ matrix_synapse_secret }}" macaroon_secret_key: "{{ matrix_macaroon_secret }}" form_secret: "{{ matrix_form_secret }}" -report_stats: {{ "true" if matrix_report_stats else "false" }} +report_stats: {{ matrix_report_stats | bool | lower }} retention: enabled: true diff --git a/roles/matrix/tasks/main.yml b/roles/matrix/tasks/main.yml index 7355fe0..96b3fc7 100644 --- a/roles/matrix/tasks/main.yml +++ b/roles/matrix/tasks/main.yml @@ -14,21 +14,20 @@ - "{{ matrix_postgres_dir }}" - name: Generate Synapse configuration - docker_container: - name: matrix-config-generator - image: matrixdotorg/synapse:latest - command: | - python -m synapse.app.homeserver \ - --server-name {{ matrix_server_name }} \ - --config-path /data/homeserver.yaml \ - --generate-config \ - --report-stats={{ "yes" if matrix_report_stats else "no" }} - volumes: - - "{{ matrix_config_dir }}:/data" - auto_remove: true + command: > + docker run --rm + -v {{ matrix_config_dir }}:/data + matrixdotorg/synapse:latest + python -m synapse.app.homeserver + --server-name {{ matrix_server_name }} + --config-path /data/homeserver.yaml + --generate-config + --report-stats={{ "yes" if matrix_report_stats else "no" }} + args: + creates: "{{ matrix_config_dir }}/homeserver.yaml" - name: Copy custom configuration files - copy: + template: src: "{{ item }}" dest: "{{ matrix_config_dir }}/" mode: 0644 @@ -45,6 +44,7 @@ loop: - "homeserver.yaml" - "log.config" + - "homeserver.yaml.generated" # если файл существует - name: Deploy Matrix docker-compose.yml template: @@ -59,6 +59,13 @@ args: executable: /bin/bash +- name: Wait for database to be ready + wait_for: + host: localhost + port: "{{ matrix_port }}" + timeout: 60 + delegate_to: localhost + - name: Wait for services to start pause: seconds: 30 @@ -80,6 +87,7 @@ docker exec matrix-synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -u admin -p {{ vault_matrix_admin_password }} --admin when: matrix_admin_user != "" and matrix_registration_enabled ignore_errors: true + become: no - name: Show connection info debug: