olimp/roles/matrix/tasks/main.yml
Administrator 300fc1d40f Update 2 files
- /roles/matrix/files/homeserver.yaml
- /roles/matrix/tasks/main.yml
2025-10-23 08:38:20 +00:00

103 lines
2.6 KiB
YAML

---
- name: Create Matrix directories
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: "991"
group: "991"
loop:
- "{{ matrix_base_dir }}"
- "{{ matrix_data_dir }}"
- "{{ matrix_config_dir }}"
- "{{ matrix_media_dir }}"
- "{{ matrix_postgres_dir }}"
- name: Generate Synapse configuration
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
template:
src: "{{ item }}"
dest: "{{ matrix_config_dir }}/"
mode: 0644
loop:
- "homeserver.yaml"
- "log.config"
- name: Set proper permissions on config files
file:
path: "{{ matrix_config_dir }}/{{ item }}"
owner: "991"
group: "991"
mode: "0644"
loop:
- "homeserver.yaml"
- "log.config"
- "homeserver.yaml.generated" # если файл существует
- name: Deploy Matrix docker-compose.yml
template:
src: "docker-compose.yml.j2"
dest: "{{ matrix_base_dir }}/docker-compose.yml"
mode: 0644
- name: Start Matrix services
shell: |
cd {{ matrix_base_dir }}
docker compose up -d
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
- name: Check Matrix container status
shell: |
docker ps --filter name=matrix-synapse
docker ps --filter name=matrix-postgres
register: matrix_status
changed_when: false
- name: Show Matrix status
debug:
var: matrix_status.stdout
- name: Register admin user (if specified)
shell: |
cd {{ matrix_base_dir }}
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:
msg: |
Matrix Synapse deployed!
Server: {{ matrix_server_name }}
Client port: {{ matrix_port }}
Admin: {{ matrix_admin_user }}
Next steps:
1. Configure reverse proxy in NPM
2. Open ports in firewall if needed
3. Configure SSL certificates