olimp/roles/matrix/tasks/main.yml
Administrator feb14eb513 Update 7 files
- /group_vars/all.yml
- /group_vars/all/vault.yml
- /roles/matrix/tasks/main.yml
- /roles/matrix/files/homeserver.yaml
- /roles/matrix/files/log.config
- /roles/matrix/templates/docker-compose.yml.j2
- /olimp-deploy.yml
2025-10-22 06:34:36 +00:00

95 lines
2.4 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
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
- name: Copy custom configuration files
copy:
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"
- 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 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
- 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