mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-14 17:01:05 +01:00
136 lines
4.5 KiB
YAML
136 lines
4.5 KiB
YAML
---
|
|
- name: "include docker/compose/database.yml"
|
|
include_tasks: docker/compose/database.yml
|
|
|
|
- name: "include task certbot-matomo.yml"
|
|
include_tasks: certbot-matomo.yml
|
|
vars:
|
|
domain: "{{synapse_domain}}"
|
|
http_port: "{{synapse_http_port}}"
|
|
|
|
- name: create {{well_known_directory}}
|
|
file:
|
|
path: "{{well_known_directory}}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: create {{well_known_directory}}server
|
|
template:
|
|
src: "well-known.j2"
|
|
dest: "{{well_known_directory}}server"
|
|
|
|
- name: create {{synapse_domain}}.conf
|
|
template:
|
|
src: "templates/nginx.conf.j2"
|
|
dest: "{{nginx_servers_directory}}{{synapse_domain}}.conf"
|
|
vars:
|
|
domain: "{{synapse_domain}}"
|
|
http_port: "{{synapse_http_port}}"
|
|
notify: restart nginx
|
|
|
|
- name: "include tasks nginx-docker-proxy-domain.yml for element"
|
|
include_tasks: nginx-docker-proxy-domain.yml
|
|
vars:
|
|
domain: "{{element_domain}}"
|
|
http_port: "{{element_http_port}}"
|
|
|
|
- name: include create-and-seed-database.yml for multiple bridges
|
|
include_tasks: create-and-seed-database.yml
|
|
vars:
|
|
database_password: "{{ item.database_password }}"
|
|
database_username: "{{ item.database_username }}"
|
|
database_name: "{{ item.database_name }}"
|
|
loop: "{{ bridges }}"
|
|
|
|
# The following taks are necessary because a clean setup is necessary
|
|
- name: shut down docker compose project
|
|
command:
|
|
cmd: docker-compose -p "{{docker_compose_project_name}}" down
|
|
chdir: "{{ docker_compose_instance_directory }}"
|
|
|
|
- name: "cleanup project folder"
|
|
file:
|
|
path: "{{docker_compose_instance_directory}}mautrix/"
|
|
state: absent
|
|
|
|
- name: "create bridge folders"
|
|
file:
|
|
path: "{{docker_compose_instance_directory}}mautrix/{{item.bridge_name}}"
|
|
state: directory
|
|
mode: 0755
|
|
loop: "{{ bridges }}"
|
|
|
|
- name: add multiple mautrix bridge configuration
|
|
template:
|
|
src: "mautrix/{{item.bridge_name}}.config.yml.j2"
|
|
dest: "{{docker_compose_instance_directory}}mautrix/{{item.bridge_name}}/config.yaml"
|
|
loop: "{{ bridges }}"
|
|
notify: docker compose project setup
|
|
|
|
- name: add element configuration
|
|
template:
|
|
src: "element.config.json.j2"
|
|
dest: "{{docker_compose_instance_directory}}element-config.json"
|
|
notify: docker compose project setup
|
|
|
|
- name: add synapse homeserver configuration
|
|
template:
|
|
src: "synapse/homeserver.yaml.j2"
|
|
dest: "{{docker_compose_instance_directory}}homeserver.yaml"
|
|
notify: docker compose project setup
|
|
|
|
- name: add synapse log configuration
|
|
template:
|
|
src: "synapse/log.config.j2"
|
|
dest: "{{docker_compose_instance_directory}}{{synapse_domain}}.log.config"
|
|
notify: docker compose project setup
|
|
|
|
# https://github.com/matrix-org/synapse/issues/6303
|
|
- name: set correct folder permissions
|
|
command:
|
|
cmd: "docker run --rm --mount type=volume,src=matrix_synapse_data,dst=/data -e SYNAPSE_SERVER_NAME={{synapse_domain}} -e SYNAPSE_REPORT_STATS=no --entrypoint /bin/sh matrixdotorg/synapse:latest -c 'chown -vR 991:991 /data'"
|
|
|
|
- name: add docker-compose.yml
|
|
template:
|
|
src: "docker-compose.yml.j2"
|
|
dest: "{{docker_compose_instance_directory}}docker-compose.yml"
|
|
notify: docker compose project setup
|
|
|
|
- name: docker compose project setup
|
|
command:
|
|
cmd: docker-compose -p "{{docker_compose_project_name}}" up -d --force-recreate
|
|
chdir: "{{docker_compose_instance_directory}}"
|
|
environment:
|
|
COMPOSE_HTTP_TIMEOUT: 600
|
|
DOCKER_CLIENT_TIMEOUT: 600
|
|
register: result
|
|
until: result is succeeded
|
|
retries: 12
|
|
delay: 30
|
|
|
|
- name: wait for registration files
|
|
wait_for:
|
|
path: "{{docker_compose_instance_directory}}mautrix/{{item.bridge_name}}/registration.yaml"
|
|
state: present
|
|
timeout: 120
|
|
loop: "{{ bridges }}"
|
|
|
|
- name: "change file permissions"
|
|
file:
|
|
path: "{{docker_compose_instance_directory}}mautrix/{{item.bridge_name}}/registration.yaml"
|
|
mode: 0755
|
|
loop: "{{ bridges }}"
|
|
|
|
- name: create admin account
|
|
command:
|
|
cmd: docker compose exec -it synapse register_new_matrix_user -u {{matrix_admin_name}} -p {{matrix_admin_password}} -a -c /data/homeserver.yaml http://localhost:8008
|
|
chdir: "{{ docker_compose_instance_directory }}"
|
|
ignore_errors: true
|
|
when: mode_setup | bool
|
|
|
|
- name: create chatgpt bot
|
|
command:
|
|
cmd: docker compose exec -it synapse register_new_matrix_user -u chatgptbot -p {{matrix_chatgpt_bridge_user_password}} -a -c /data/homeserver.yaml http://localhost:8008
|
|
chdir: "{{ docker_compose_instance_directory }}"
|
|
ignore_errors: true
|
|
when: mode_setup | bool |