mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Huge role refactoring/cleanup. Other commits will propably follow. Because some bugs will exist. Still important for longrun and also for auto docs/help/slideshow generation
This commit is contained in:
13
roles/web-app-matrix/tasks/create-and-seed-database.yml
Normal file
13
roles/web-app-matrix/tasks/create-and-seed-database.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
# The following parameters need to be pased:
|
||||
#
|
||||
# - database_instance
|
||||
# - database_name
|
||||
# - database_username
|
||||
# - database_password
|
||||
- name: "create {{database_name}} database"
|
||||
include_role:
|
||||
name: service-rdbms-postgres
|
||||
when: applications | is_feature_enabled('central_database',application_id)
|
||||
|
||||
- name: "include seed-database-to-backup.yml"
|
||||
include_tasks: "{{ playbook_dir }}/roles/backup-docker-to-local/tasks/seed-database-to-backup.yml"
|
156
roles/web-app-matrix/tasks/main.yml
Normal file
156
roles/web-app-matrix/tasks/main.yml
Normal file
@@ -0,0 +1,156 @@
|
||||
---
|
||||
- name: Load bridges configuration
|
||||
include_vars:
|
||||
file: "bridges.yml"
|
||||
|
||||
- name: Filter enabled bridges and register as fact
|
||||
set_fact:
|
||||
bridges: "{{ bridges_configuration | filter_enabled_bridges(applications[application_id].plugins) }}"
|
||||
changed_when: false
|
||||
|
||||
- name: "include service-rdbms-central"
|
||||
include_role:
|
||||
name: service-rdbms-central
|
||||
|
||||
- name: "include role for {{application_id}} to receive certs & do modification routines"
|
||||
include_role:
|
||||
name: webserver-composer
|
||||
vars:
|
||||
domain: "{{domains.matrix.synapse}}"
|
||||
http_port: "{{ports.localhost.http.synapse}}"
|
||||
|
||||
- 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 {{domains.matrix.synapse}}.conf
|
||||
template:
|
||||
src: "templates/nginx.conf.j2"
|
||||
dest: "{{nginx.directories.http.servers}}{{domains.matrix.synapse}}.conf"
|
||||
vars:
|
||||
domain: "{{domains.matrix.synapse}}" # Didn't work in the past. May it works now. This does not seem to work @todo Check how to solve without declaring set_fact, seems a bug at templates
|
||||
http_port: "{{ports.localhost.http.synapse}}"
|
||||
notify: restart nginx
|
||||
|
||||
- name: "include role webserver-proxy-domain for {{application_id}}"
|
||||
include_role:
|
||||
name: webserver-proxy-domain
|
||||
vars:
|
||||
domain: "{{domains.matrix.element}}"
|
||||
http_port: "{{ports.localhost.http.element}}"
|
||||
|
||||
- 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 "{{application_id}}" down
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
|
||||
- name: "cleanup project folder"
|
||||
file:
|
||||
path: "{{docker_compose.directories.instance}}mautrix/"
|
||||
state: absent
|
||||
|
||||
- name: "create bridge folders"
|
||||
file:
|
||||
path: "{{docker_compose.directories.instance}}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.directories.instance}}mautrix/{{item.bridge_name}}/config.yaml"
|
||||
loop: "{{ bridges }}"
|
||||
notify: docker compose up
|
||||
|
||||
- name: add element configuration
|
||||
template:
|
||||
src: "element.config.json.j2"
|
||||
dest: "{{docker_compose.directories.instance}}element-config.json"
|
||||
notify: docker compose up
|
||||
|
||||
- name: add synapse homeserver configuration
|
||||
template:
|
||||
src: "synapse/homeserver.yaml.j2"
|
||||
dest: "{{docker_compose.directories.instance}}homeserver.yaml"
|
||||
notify: docker compose up
|
||||
|
||||
- name: add synapse log configuration
|
||||
template:
|
||||
src: "synapse/log.config.j2"
|
||||
dest: "{{docker_compose.directories.instance}}{{domains.matrix.synapse}}.log.config"
|
||||
notify: docker compose up
|
||||
|
||||
# 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={{domains.matrix.synapse}} -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.directories.instance}}docker-compose.yml"
|
||||
notify: docker compose up
|
||||
|
||||
# Pull image when update is wished.
|
||||
# @todo This should be moved to update-docker
|
||||
- name: docker compose pull
|
||||
command:
|
||||
cmd: docker-compose -p "{{application_id}}" pull
|
||||
chdir: "{{docker_compose.directories.instance}}"
|
||||
when: mode_update | bool
|
||||
|
||||
- name: docker compose up
|
||||
command:
|
||||
cmd: "docker-compose -p {{application_id}} up -d --remove-orphans"
|
||||
chdir: "{{docker_compose.directories.instance}}"
|
||||
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.directories.instance}}mautrix/{{item.bridge_name}}/registration.yaml"
|
||||
state: present
|
||||
timeout: 120
|
||||
loop: "{{ bridges }}"
|
||||
|
||||
- name: "change file permissions"
|
||||
file:
|
||||
path: "{{docker_compose.directories.instance}}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 {{applications[application_id].users.administrator.username}} -p {{applications[application_id].credentials.administrator_password}} -a -c /data/homeserver.yaml http://localhost:8008
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
ignore_errors: true
|
||||
when: applications[application_id].setup | bool
|
||||
|
||||
- name: create chatgpt bot
|
||||
command:
|
||||
cmd: docker compose exec -it synapse register_new_matrix_user -u chatgptbot -p {{applications[application_id].credentials.chatgpt_bridge_user_password}} -a -c /data/homeserver.yaml http://localhost:8008
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
ignore_errors: true
|
||||
when: applications[application_id].setup | bool
|
Reference in New Issue
Block a user