Merge branch 'master' into conduit
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup.yml"
|
||||
when: run_stop|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml"
|
||||
when: run_stop | bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-aux-files
|
||||
|
@ -1,19 +1,19 @@
|
||||
---
|
||||
|
||||
- name: Ensure AUX directories are created
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
dest: "{{ item.dest }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner|default(matrix_user_username) }}"
|
||||
group: "{{ item.group|default(matrix_user_groupname) }}"
|
||||
mode: "{{ item.mode|default(matrix_aux_directory_default_mode) }}"
|
||||
owner: "{{ item.owner | default(matrix_user_username) }}"
|
||||
group: "{{ item.group | default(matrix_user_groupname) }}"
|
||||
mode: "{{ item.mode | default(matrix_aux_directory_default_mode) }}"
|
||||
with_items: "{{ matrix_aux_directory_definitions }}"
|
||||
|
||||
- name: Ensure AUX files are created
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ item.dest }}"
|
||||
content: "{{ item.content }}"
|
||||
owner: "{{ item.owner|default(matrix_user_username) }}"
|
||||
group: "{{ item.group|default(matrix_user_groupname) }}"
|
||||
mode: "{{ item.mode|default(matrix_aux_file_default_mode) }}"
|
||||
owner: "{{ item.owner | default(matrix_user_username) }}"
|
||||
group: "{{ item.group | default(matrix_user_groupname) }}"
|
||||
mode: "{{ item.mode | default(matrix_aux_file_default_mode) }}"
|
||||
with_items: "{{ matrix_aux_file_definitions }}"
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
# Project source code URL: https://gitlab.com/etke.cc/borgmatic
|
||||
|
||||
matrix_backup_borg_enabled: true
|
||||
|
||||
matrix_backup_borg_base_path: "{{ matrix_base_data_path }}/backup-borg"
|
||||
@ -6,13 +8,14 @@ matrix_backup_borg_config_path: "{{ matrix_backup_borg_base_path }}/config"
|
||||
|
||||
matrix_backup_borg_container_image_self_build: false
|
||||
matrix_backup_borg_docker_repo: "https://gitlab.com/etke.cc/borgmatic"
|
||||
matrix_backup_borg_docker_repo_version: main
|
||||
matrix_backup_borg_docker_src_files_path: "{{ matrix_backup_borg_base_path }}/docker-src"
|
||||
|
||||
# version determined automatically, based on postgres server version (if enabled), otherwise latest is used
|
||||
matrix_backup_borg_version: ""
|
||||
matrix_backup_borg_docker_image: "{{ matrix_backup_borg_docker_image_name_prefix }}etke.cc/borgmatic:{{ matrix_backup_borg_version }}"
|
||||
matrix_backup_borg_docker_image_name_prefix: "{{ 'localhost/' if matrix_backup_borg_container_image_self_build else 'registry.gitlab.com/' }}"
|
||||
matrix_backup_borg_docker_image_force_pull: "{{ matrix_backup_borg_docker_image.endswith(':latest') or matrix_backup_borg_version|default('') == '' }}"
|
||||
matrix_backup_borg_docker_image_force_pull: "{{ matrix_backup_borg_docker_image.endswith(':latest') or matrix_backup_borg_version | default('') == '' }}"
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_backup_borg_container_extra_arguments: []
|
||||
@ -91,8 +94,8 @@ matrix_backup_borg_configuration_extension_yaml: |
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_backup_borg_configuration_yaml`.
|
||||
|
||||
matrix_backup_borg_configuration_extension: "{{ matrix_backup_borg_configuration_extension_yaml|from_yaml if matrix_backup_borg_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_backup_borg_configuration_extension: "{{ matrix_backup_borg_configuration_extension_yaml | from_yaml if matrix_backup_borg_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
# Holds the final borgmatic configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_backup_borg_configuration_yaml`.
|
||||
matrix_backup_borg_configuration: "{{ matrix_backup_borg_configuration_yaml|from_yaml|combine(matrix_backup_borg_configuration_extension, recursive=True) }}"
|
||||
matrix_backup_borg_configuration: "{{ matrix_backup_borg_configuration_yaml | from_yaml | combine(matrix_backup_borg_configuration_extension, recursive=True) }}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
---
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-backup-borg.service', 'matrix-backup-borg.timer'] }}"
|
||||
when: matrix_backup_borg_enabled|bool
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-backup-borg.timer'] }}"
|
||||
when: matrix_backup_borg_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_backup_borg_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_backup_borg_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-backup-borg
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_backup_borg_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_backup_borg_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-backup-borg
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_backup_borg_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_backup_borg_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-backup-borg
|
||||
|
@ -1,19 +1,29 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/detect_existing_postgres_version.yml"
|
||||
- name: Fail with matrix_backup_borg_version advice if Postgres not enabled
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You are not running a built-in Postgres server (`matrix_postgres_enabled: false`), so auto-detecting its version and setting `matrix_backup_borg_version` automatically based on that cannot happen.
|
||||
Consider setting `matrix_backup_borg_version` to your Postgres version manually.
|
||||
when: not matrix_postgres_enabled
|
||||
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: detect_existing_postgres_version
|
||||
|
||||
- name: Fail if detected Postgres version is unsupported
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "You cannot use borg backup with such an old version ({{ matrix_postgres_detected_version }}) of Postgres. Consider upgrading - link to docs for upgrading Postgres: docs/maintenance-postgres.md#upgrading-postgresql"
|
||||
when: "matrix_postgres_detected_version not in matrix_backup_borg_supported_postgres_versions"
|
||||
|
||||
- name: Set the correct borg backup version to use
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
matrix_backup_borg_version: "{{ matrix_postgres_detected_version }}"
|
||||
when: matrix_backup_borg_postgresql_enabled|bool and matrix_backup_borg_version == ''
|
||||
when: matrix_backup_borg_postgresql_enabled | bool and matrix_backup_borg_version == ''
|
||||
|
||||
- name: Ensure borg paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -22,18 +32,18 @@
|
||||
with_items:
|
||||
- {path: "{{ matrix_backup_borg_config_path }}", when: true}
|
||||
- {path: "{{ matrix_backup_borg_docker_src_files_path }}", when: true}
|
||||
when: "item.when|bool"
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure borgmatic config is created
|
||||
copy:
|
||||
content: "{{ matrix_backup_borg_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_backup_borg_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_backup_borg_config_path }}/config.yaml"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure borg passwd is created
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/passwd.j2"
|
||||
dest: "{{ matrix_backup_borg_config_path }}/passwd"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
@ -41,7 +51,7 @@
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure borg ssh key is created
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/sshkey.j2"
|
||||
dest: "{{ matrix_backup_borg_config_path }}/sshkey"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
@ -54,21 +64,22 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_backup_borg_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_backup_borg_docker_image_force_pull }}"
|
||||
when: "not matrix_backup_borg_container_image_self_build|bool"
|
||||
when: "not matrix_backup_borg_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure borg repository is present on self-build
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_backup_borg_docker_repo }}"
|
||||
version: "{{ matrix_backup_borg_docker_repo_version }}"
|
||||
dest: "{{ matrix_backup_borg_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_backup_borg_git_pull_results
|
||||
when: "matrix_backup_borg_container_image_self_build|bool"
|
||||
when: "matrix_backup_borg_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure borg image is built
|
||||
docker_image:
|
||||
@ -80,33 +91,33 @@
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_backup_borg_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_backup_borg_container_image_self_build|bool"
|
||||
when: "matrix_backup_borg_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-backup-borg.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
|
||||
mode: 0644
|
||||
register: matrix_backup_borg_systemd_service_result
|
||||
|
||||
- name: Ensure matrix-backup-borg.timer installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
|
||||
mode: 0644
|
||||
register: matrix_backup_borg_systemd_timer_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-backup-borg.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_backup_borg_systemd_service_result.changed|bool"
|
||||
when: "matrix_backup_borg_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-backup-borg.service enabled
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
enabled: true
|
||||
name: matrix-backup-borg.service
|
||||
|
||||
- name: Ensure matrix-backup-borg.timer enabled
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
enabled: true
|
||||
name: matrix-backup-borg.timer
|
||||
|
@ -1,37 +1,37 @@
|
||||
---
|
||||
- name: Check existence of matrix-backup-borg service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
|
||||
register: matrix_backup_borg_service_stat
|
||||
|
||||
- name: Ensure matrix-backup-borg is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-backup-borg
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_backup_borg_service_stat.stat.exists|bool"
|
||||
when: "matrix_backup_borg_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-backup-borg.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
|
||||
state: absent
|
||||
when: "matrix_backup_borg_service_stat.stat.exists|bool"
|
||||
when: "matrix_backup_borg_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-backup-borg.timer doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
|
||||
state: absent
|
||||
when: "matrix_backup_borg_service_stat.stat.exists|bool"
|
||||
when: "matrix_backup_borg_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-backup-borg.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_backup_borg_service_stat.stat.exists|bool"
|
||||
when: "matrix_backup_borg_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix borg paths don't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_backup_borg_base_path }}"
|
||||
state: absent
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
@ -9,7 +9,7 @@
|
||||
- "matrix_backup_borg_location_repositories"
|
||||
|
||||
- name: Fail if encryption passphrase is undefined unless repository is unencrypted
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required passphrase using the `matrix_backup_borg_storage_encryption_passphrase` variable.
|
||||
when: "matrix_backup_borg_storage_encryption_passphrase == '' and matrix_backup_borg_encryption != 'none'"
|
||||
|
@ -8,6 +8,25 @@
|
||||
# Example value: example.com
|
||||
matrix_domain: ~
|
||||
|
||||
# The optional matrix admin MXID, used in bridges' configs to set bridge admin user
|
||||
# Example value: "@someone:{{ matrix_domain }}"
|
||||
matrix_admin: ''
|
||||
|
||||
# Homeserver admin contacts and support page as per MSC 1929
|
||||
# See: https://github.com/matrix-org/matrix-spec-proposals/pull/1929
|
||||
# Users in form:
|
||||
# matrix_homeserver_admin_contacts:
|
||||
# - matrix_id: @admin:domain.tld
|
||||
# email_address: admin@domain.tld
|
||||
# role: admin
|
||||
# - email_address: security@domain.tld
|
||||
# role: security
|
||||
# Also see: `matrix_well_known_matrix_support_enabled`
|
||||
matrix_homeserver_admin_contacts: []
|
||||
# Url string like https://domain.tld/support.html
|
||||
# Also see: `matrix_well_known_matrix_support_enabled`
|
||||
matrix_homeserver_support_url: ''
|
||||
|
||||
# This will contain the homeserver implementation that is in use.
|
||||
# Valid values: synapse, dendrite, conduit
|
||||
#
|
||||
@ -37,6 +56,9 @@ matrix_server_fqn_hydrogen: "hydrogen.{{ matrix_domain }}"
|
||||
# This is where you access the Cinny web client from (if enabled via matrix_client_cinny_enabled; disabled by default).
|
||||
matrix_server_fqn_cinny: "cinny.{{ matrix_domain }}"
|
||||
|
||||
# This is where you access the buscarron bot from (if enabled via matrix_bot_buscarron_enabled; disabled by default).
|
||||
matrix_server_fqn_buscarron: "buscarron.{{ matrix_domain }}"
|
||||
|
||||
# This is where you access the Dimension.
|
||||
matrix_server_fqn_dimension: "dimension.{{ matrix_domain }}"
|
||||
|
||||
@ -52,6 +74,9 @@ matrix_server_fqn_grafana: "stats.{{ matrix_domain }}"
|
||||
# This is where you access the Sygnal push gateway.
|
||||
matrix_server_fqn_sygnal: "sygnal.{{ matrix_domain }}"
|
||||
|
||||
# This is where you access the ntfy push notification service.
|
||||
matrix_server_fqn_ntfy: "ntfy.{{ matrix_domain }}"
|
||||
|
||||
matrix_federation_public_port: 8448
|
||||
|
||||
# The architecture that your server runs.
|
||||
@ -71,6 +96,10 @@ matrix_container_global_registry_prefix: "docker.io/"
|
||||
matrix_container_retries_count: 10
|
||||
matrix_container_retries_delay: 10
|
||||
|
||||
# Each get_url will retry on failed attempt 10 times with delay of 10 seconds between each attempt.
|
||||
matrix_geturl_retries_count: 10
|
||||
matrix_geturl_retries_delay: 10
|
||||
|
||||
matrix_user_username: "matrix"
|
||||
matrix_user_groupname: "matrix"
|
||||
|
||||
@ -105,8 +134,8 @@ matrix_host_command_openssl: "/usr/bin/env openssl"
|
||||
matrix_host_command_systemctl: "/usr/bin/env systemctl"
|
||||
matrix_host_command_sh: "/usr/bin/env sh"
|
||||
|
||||
matrix_ntpd_package: "{{ 'systemd-timesyncd' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version|int > 7) or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int > 18) else ( 'systemd' if ansible_os_family == 'Suse' else 'ntp' ) }}"
|
||||
matrix_ntpd_service: "{{ 'systemd-timesyncd' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version|int > 7) or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int > 18) or ansible_distribution == 'Archlinux' or ansible_os_family == 'Suse' else ('ntpd' if ansible_os_family == 'RedHat' else 'ntp') }}"
|
||||
matrix_ntpd_package: "{{ 'systemd-timesyncd' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 7) or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version | int > 18) else ( 'systemd' if ansible_os_family == 'Suse' else 'ntp' ) }}"
|
||||
matrix_ntpd_service: "{{ 'systemd-timesyncd' if (ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 7) or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version | int > 18) or ansible_distribution == 'Archlinux' or ansible_os_family == 'Suse' else ('ntpd' if ansible_os_family == 'RedHat' else 'ntp') }}"
|
||||
|
||||
matrix_homeserver_url: "https://{{ matrix_server_fqn_matrix }}"
|
||||
|
||||
@ -128,7 +157,7 @@ matrix_integration_manager_ui_url: ~
|
||||
# The domain name where a Jitsi server is self-hosted.
|
||||
# If set, `/.well-known/matrix/client` will suggest Element clients to use that Jitsi server.
|
||||
# See: https://github.com/vector-im/element-web/blob/develop/docs/jitsi.md#configuring-element-to-use-your-self-hosted-jitsi-server
|
||||
matrix_client_element_jitsi_preferredDomain: ''
|
||||
matrix_client_element_jitsi_preferredDomain: '' # noqa var-naming
|
||||
|
||||
# Controls whether Element should use End-to-End Encryption by default.
|
||||
# Setting this to false will update `/.well-known/matrix/client` and tell Element clients to avoid E2EE.
|
||||
@ -173,11 +202,11 @@ matrix_well_known_matrix_client_configuration_default: "{{ lookup('template', 't
|
||||
# }
|
||||
matrix_well_known_matrix_client_configuration_extension_json: '{}'
|
||||
|
||||
matrix_well_known_matrix_client_configuration_extension: "{{ matrix_well_known_matrix_client_configuration_extension_json|from_json if matrix_well_known_matrix_client_configuration_extension_json|from_json is mapping else {} }}"
|
||||
matrix_well_known_matrix_client_configuration_extension: "{{ matrix_well_known_matrix_client_configuration_extension_json | from_json if matrix_well_known_matrix_client_configuration_extension_json | from_json is mapping else {} }}"
|
||||
|
||||
# Holds the final `/.well-known/matrix/client` configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_well_known_matrix_client_configuration_default` and `matrix_well_known_matrix_client_configuration_extension_json`.
|
||||
matrix_well_known_matrix_client_configuration: "{{ matrix_well_known_matrix_client_configuration_default|combine(matrix_well_known_matrix_client_configuration_extension, recursive=True) }}"
|
||||
matrix_well_known_matrix_client_configuration: "{{ matrix_well_known_matrix_client_configuration_default | combine(matrix_well_known_matrix_client_configuration_extension, recursive=True) }}"
|
||||
|
||||
# Default `/.well-known/matrix/server` configuration - it covers the generic use case.
|
||||
# You can customize it by controlling the various variables inside the template file that it references.
|
||||
@ -205,11 +234,23 @@ matrix_well_known_matrix_server_configuration_default: "{{ lookup('template', 't
|
||||
# }
|
||||
matrix_well_known_matrix_server_configuration_extension_json: '{}'
|
||||
|
||||
matrix_well_known_matrix_server_configuration_extension: "{{ matrix_well_known_matrix_server_configuration_extension_json|from_json if matrix_well_known_matrix_server_configuration_extension_json|from_json is mapping else {} }}"
|
||||
matrix_well_known_matrix_server_configuration_extension: "{{ matrix_well_known_matrix_server_configuration_extension_json | from_json if matrix_well_known_matrix_server_configuration_extension_json | from_json is mapping else {} }}"
|
||||
|
||||
# Holds the final `/.well-known/matrix/server` configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_well_known_matrix_server_configuration_default` and `matrix_well_known_matrix_server_configuration_extension_json`.
|
||||
matrix_well_known_matrix_server_configuration: "{{ matrix_well_known_matrix_server_configuration_default|combine(matrix_well_known_matrix_server_configuration_extension, recursive=True) }}"
|
||||
matrix_well_known_matrix_server_configuration: "{{ matrix_well_known_matrix_server_configuration_default | combine(matrix_well_known_matrix_server_configuration_extension, recursive=True) }}"
|
||||
|
||||
# The side-effect of this lookup is that Ansible would even parse the JSON for us, returning a dict.
|
||||
# This is unlike what it does when looking up YAML template files (no automatic parsing there).
|
||||
matrix_well_known_matrix_support_configuration_default: "{{ lookup('template', 'templates/static-files/well-known/matrix-support.j2') }}"
|
||||
|
||||
matrix_well_known_matrix_support_configuration_extension_json: '{}'
|
||||
|
||||
matrix_well_known_matrix_support_configuration_extension: "{{ matrix_well_known_matrix_support_configuration_extension_json | from_json if matrix_well_known_matrix_support_configuration_extension_json | from_json is mapping else {} }}"
|
||||
|
||||
# Holds the final `/.well-known/matrix/support` configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_well_known_matrix_support_configuration_default` and `matrix_well_known_matrix_support_configuration_extension_json`.
|
||||
matrix_well_known_matrix_support_configuration: "{{ matrix_well_known_matrix_support_configuration_default | combine(matrix_well_known_matrix_support_configuration_extension, recursive=True) }}"
|
||||
|
||||
# The Docker network that all services would be put into
|
||||
matrix_docker_network: "matrix"
|
||||
@ -228,6 +269,13 @@ matrix_vars_yml_snapshotting_src: "{{ inventory_dir }}/host_vars/{{ inventory_ho
|
||||
# matrix domain (`matrix_server_fqn_matrix`).
|
||||
matrix_well_known_matrix_server_enabled: true
|
||||
|
||||
# Controls whether a `/.well-known/matrix/support` file is generated and used at all.
|
||||
#
|
||||
# This is not enabled by default, until the MSC gets accepted: https://github.com/matrix-org/matrix-spec-proposals/pull/1929
|
||||
#
|
||||
# See `matrix_homeserver_admin_contacts`, `matrix_homeserver_support_url`, etc.
|
||||
matrix_well_known_matrix_support_enabled: false
|
||||
|
||||
# Controls whether Docker is automatically installed.
|
||||
# If you change this to false you must install and update Docker manually. You also need to install the docker (https://pypi.org/project/docker/) Python package.
|
||||
matrix_docker_installation_enabled: true
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Get rid of old files and directories
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
|
@ -1,34 +1,34 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/sanity_check.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/sanity_check.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/clean_up_old_files.yml"
|
||||
when: run_setup|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/clean_up_old_files.yml"
|
||||
when: run_setup | bool
|
||||
tags:
|
||||
- setup-all
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/server_base/setup.yml"
|
||||
when: run_setup|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/server_base/setup.yml"
|
||||
when: run_setup | bool
|
||||
tags:
|
||||
- setup-all
|
||||
|
||||
# This needs to always run, because it populates `matrix_user_uid` and `matrix_user_gid`,
|
||||
# which are required by many other roles.
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_matrix_user.yml"
|
||||
when: run_setup|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_matrix_user.yml"
|
||||
when: run_setup | bool
|
||||
tags:
|
||||
- always
|
||||
- setup-system-user
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_matrix_base.yml"
|
||||
when: run_setup|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_matrix_base.yml"
|
||||
when: run_setup | bool
|
||||
tags:
|
||||
- setup-all
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_well_known.yml"
|
||||
when: run_setup|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_well_known.yml"
|
||||
when: run_setup | bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-ma1sd
|
||||
|
@ -1,27 +1,27 @@
|
||||
---
|
||||
|
||||
- name: Fail if invalid homeserver implementation
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "You need to set a valid homeserver implementation in `matrix_homeserver_implementation`"
|
||||
when: "matrix_homeserver_implementation not in ['synapse', 'dendrite', 'conduit']"
|
||||
|
||||
# We generally support Ansible 2.7.1 and above.
|
||||
- name: Fail if running on Ansible < 2.7.1
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "You are running on Ansible {{ ansible_version.string }}, which is not supported. See our guide about Ansible: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/ansible.md"
|
||||
when:
|
||||
- "(ansible_version.major < 2) or (ansible_version.major == 2 and ansible_version.minor < 7) or (ansible_version.major == 2 and ansible_version.minor == 7 and ansible_version.revision < 1)"
|
||||
|
||||
# Though we do not support Ansible 2.9.6 which is buggy
|
||||
- name: Fail if running on Ansible 2.9.6 on Ubuntu
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "You are running on Ansible {{ ansible_version.string }}, which is not supported. See our guide about Ansible: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/ansible.md"
|
||||
when:
|
||||
- ansible_distribution == 'Ubuntu'
|
||||
- "ansible_version.major == 2 and ansible_version.minor == 9 and ansible_version.revision == 6"
|
||||
|
||||
- name: (Deprecation) Catch and report renamed settings
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
# We have a dedicated check for this variable, because we'd like to have a custom (friendlier) message.
|
||||
- name: Fail if matrix_homeserver_generic_secret_key is undefined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: |
|
||||
The `matrix_homeserver_generic_secret_key` variable must be defined and have a non-null and non-empty value.
|
||||
|
||||
@ -47,35 +47,45 @@
|
||||
when: "matrix_homeserver_generic_secret_key is none or matrix_homeserver_generic_secret_key == ''"
|
||||
|
||||
- name: Fail if required variables are undefined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "The `{{ item.var }}` variable must be defined and have a non-null and non-empty value"
|
||||
with_items:
|
||||
- {'var': matrix_domain, 'value': "{{ matrix_domain|default('') }}"}
|
||||
- {'var': matrix_server_fqn_matrix, 'value': "{{ matrix_server_fqn_matrix|default('') }}"}
|
||||
- {'var': matrix_server_fqn_element, 'value': "{{ matrix_server_fqn_element|default('') }}"}
|
||||
- {'var': matrix_homeserver_container_url, 'value': "{{ matrix_homeserver_container_url|default('') }}"}
|
||||
- {'var': matrix_homeserver_container_federation_url, 'value': "{{ matrix_homeserver_container_federation_url|default('') }}"}
|
||||
- {'var': matrix_domain, 'value': "{{ matrix_domain | default('') }}"}
|
||||
- {'var': matrix_server_fqn_matrix, 'value': "{{ matrix_server_fqn_matrix | default('') }}"}
|
||||
- {'var': matrix_server_fqn_element, 'value': "{{ matrix_server_fqn_element | default('') }}"}
|
||||
- {'var': matrix_homeserver_container_url, 'value': "{{ matrix_homeserver_container_url | default('') }}"}
|
||||
- {'var': matrix_homeserver_container_federation_url, 'value': "{{ matrix_homeserver_container_federation_url | default('') }}"}
|
||||
when: "item.value is none or item.value == ''"
|
||||
|
||||
- name: Fail if uppercase domain used
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Detected that you're using an uppercase domain name - `{{ item }}`. This will cause trouble. Please use all-lowercase!"
|
||||
with_items:
|
||||
- "{{ matrix_domain }}"
|
||||
- "{{ matrix_server_fqn_matrix }}"
|
||||
- "{{ matrix_server_fqn_element }}"
|
||||
when: "item != item|lower"
|
||||
when: "item != item | lower"
|
||||
|
||||
- name: Fail if using python2 on Archlinux
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Detected that you're using python2 when installing onto Archlinux. Archlinux by default only supports python3."
|
||||
when:
|
||||
- ansible_distribution == 'Archlinux'
|
||||
- ansible_python.version.major != 3
|
||||
|
||||
- name: Fail if architecture is set incorrectly
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Detected that variable matrix_architecture {{ matrix_architecture }} appears to be set incorrectly. See docs/alternative-architectures.md. Server appears to be {{ ansible_architecture }}."
|
||||
when: (ansible_architecture == "x86_64" and matrix_architecture != "amd64") or
|
||||
(ansible_architecture == "aarch64" and matrix_architecture != "arm64") or
|
||||
(ansible_architecture.startswith("armv") and matrix_architecture != "arm32")
|
||||
|
||||
- name: Fail if encountering usage of removed role (mx-puppet-skype)
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration seems to include a reference to `matrix_mx_puppet_skype_enabled`. Are you trying to install the mx-puppet-skype bridge?
|
||||
The playbook no longer includes a role for installing mx-puppet-skype, because the mx-puppet-bridge is unmaintained and has been reported as broken for a long time.
|
||||
To get rid of this error, remove all `matrix_mx_puppet_*` references from your configuration.
|
||||
To clean up your server from mx-puppet-skype's presence, see this changelog entry: https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/CHANGELOG.md#mx-puppet-skype-removal.
|
||||
If you still need bridging to Skype, consider switching to the go-skype bridge instead. See `docs/configuring-playbook-bridge-go-skype-bridge.md`.
|
||||
when: "'matrix_mx_puppet_skype_enabled' in vars"
|
||||
|
@ -1,18 +1,18 @@
|
||||
---
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int < 8
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat8.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int > 7 and ansible_distribution_major_version|int < 30
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat8.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 7 and ansible_distribution_major_version | int < 30
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int > 30
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml"
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 30
|
||||
|
||||
- block:
|
||||
# ansible_lsb is only available if lsb-release is installed.
|
||||
- name: Ensure lsb-release installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- lsb-release
|
||||
state: present
|
||||
@ -20,27 +20,27 @@
|
||||
register: lsb_release_installation_result
|
||||
|
||||
- name: Reread ansible_lsb facts if lsb-release got installed
|
||||
setup: filter=ansible_lsb*
|
||||
ansible.builtin.setup: filter=ansible_lsb*
|
||||
when: lsb_release_installation_result.changed
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml"
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_debian.yml"
|
||||
when: (ansible_os_family == 'Debian') and (ansible_lsb.id != 'Raspbian')
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml"
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_raspbian.yml"
|
||||
when: (ansible_os_family == 'Debian') and (ansible_lsb.id == 'Raspbian')
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml"
|
||||
- ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml"
|
||||
when: ansible_distribution == 'Archlinux'
|
||||
|
||||
- name: Ensure Docker is started and autoruns
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: "Ensure {{ matrix_ntpd_service }} is started and autoruns"
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "{{ matrix_ntpd_service }}"
|
||||
state: started
|
||||
enabled: true
|
||||
|
@ -5,12 +5,12 @@
|
||||
name:
|
||||
- python-docker
|
||||
- python-dnspython
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
pacman:
|
||||
name:
|
||||
- docker
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure APT usage dependencies are installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
@ -10,32 +10,32 @@
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker's APT key is trusted
|
||||
apt_key:
|
||||
url: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg"
|
||||
ansible.builtin.apt_key:
|
||||
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
|
||||
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
|
||||
state: present
|
||||
register: add_repository_key
|
||||
ignore_errors: true
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure Docker repository is enabled
|
||||
apt_repository:
|
||||
repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable"
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
update_cache: true
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure APT packages are installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "{{ matrix_ntpd_package }}"
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "{{ matrix_docker_package_name }}"
|
||||
- "python{{'3' if ansible_python.version.major == 3 else ''}}-docker"
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
- "python{{ '3' if ansible_python.version.major == 3 else '' }}-docker"
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure Docker repository is enabled
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/files/yum.repos.d/{{ item }}"
|
||||
dest: "/etc/yum.repos.d/docker-ce.repo"
|
||||
owner: "root"
|
||||
@ -9,31 +9,31 @@
|
||||
mode: 0644
|
||||
with_items:
|
||||
- docker-ce-fedora.repo
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure Docker's RPM key is trusted
|
||||
rpm_key:
|
||||
ansible.builtin.rpm_key:
|
||||
state: present
|
||||
key: https://download.docker.com/linux/fedora/gpg
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure yum packages are installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_ntpd_package }}"
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_docker_package_name }}"
|
||||
- python3-pip
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
||||
- name: Ensure Docker-Py is installed
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: docker-py
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure APT usage dependencies are installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
@ -10,32 +10,32 @@
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker's APT key is trusted
|
||||
apt_key:
|
||||
ansible.builtin.apt_key:
|
||||
url: https://download.docker.com/linux/raspbian/gpg
|
||||
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
|
||||
state: present
|
||||
register: add_repository_key
|
||||
ignore_errors: true
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure Docker repository is enabled
|
||||
apt_repository:
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
update_cache: true
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure APT packages are installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "{{ matrix_ntpd_package }}"
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- "{{ matrix_docker_package_name }}"
|
||||
- "python{{'3' if ansible_python.version.major == 3 else ''}}-docker"
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,31 +1,31 @@
|
||||
---
|
||||
|
||||
- name: Ensure Docker repository is enabled
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo"
|
||||
dest: "/etc/yum.repos.d/docker-ce.repo"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0644
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure Docker's RPM key is trusted
|
||||
rpm_key:
|
||||
ansible.builtin.rpm_key:
|
||||
state: present
|
||||
key: https://download.docker.com/linux/centos/gpg
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure yum packages are installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_ntpd_package }}"
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_docker_package_name }}"
|
||||
- docker-python
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,44 +1,44 @@
|
||||
---
|
||||
|
||||
- name: Ensure Docker repository is enabled
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo"
|
||||
dest: "/etc/yum.repos.d/docker-ce.repo"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0644
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure Docker's RPM key is trusted
|
||||
rpm_key:
|
||||
ansible.builtin.rpm_key:
|
||||
state: present
|
||||
key: https://download.docker.com/linux/centos/gpg
|
||||
when: matrix_docker_installation_enabled|bool and matrix_docker_package_name == 'docker-ce'
|
||||
when: matrix_docker_installation_enabled | bool and matrix_docker_package_name == 'docker-ce'
|
||||
|
||||
- name: Ensure EPEL is installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- epel-release
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure yum packages are installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_ntpd_package }}"
|
||||
state: latest
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Ensure Docker is installed
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- "{{ matrix_docker_package_name }}"
|
||||
- python3-pip
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
||||
- name: Ensure Docker-Py is installed
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: docker-py
|
||||
state: latest
|
||||
when: matrix_docker_installation_enabled|bool
|
||||
state: present
|
||||
when: matrix_docker_installation_enabled | bool
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Ensure Matrix base path exists
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: "{{ matrix_base_data_path_mode }}"
|
||||
@ -11,13 +11,13 @@
|
||||
- "{{ matrix_base_data_path }}"
|
||||
|
||||
- name: Preserve vars.yml on the server for easily restoring if it gets lost later on
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "{{ matrix_vars_yml_snapshotting_src }}"
|
||||
dest: "{{ matrix_base_data_path }}/vars.yml"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: '0660'
|
||||
when: "matrix_vars_yml_snapshotting_enabled|bool"
|
||||
when: "matrix_vars_yml_snapshotting_enabled | bool"
|
||||
|
||||
- name: Ensure Matrix network is created in Docker
|
||||
docker_network:
|
||||
@ -25,7 +25,7 @@
|
||||
driver: bridge
|
||||
|
||||
- name: Ensure matrix-remove-all script created
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
|
||||
dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
|
||||
mode: 0750
|
||||
|
@ -1,18 +1,18 @@
|
||||
---
|
||||
|
||||
- name: Ensure Matrix group is created
|
||||
group:
|
||||
ansible.builtin.group:
|
||||
name: "{{ matrix_user_groupname }}"
|
||||
gid: "{{ omit if matrix_user_gid is none else matrix_user_gid }}"
|
||||
state: present
|
||||
register: matrix_group
|
||||
|
||||
- name: Set Matrix Group GID Variable
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
matrix_user_gid: "{{ matrix_group.gid }}"
|
||||
|
||||
- name: Ensure Matrix user is created
|
||||
user:
|
||||
ansible.builtin.user:
|
||||
name: "{{ matrix_user_username }}"
|
||||
uid: "{{ omit if matrix_user_uid is none else matrix_user_uid }}"
|
||||
state: present
|
||||
@ -23,5 +23,5 @@
|
||||
register: matrix_user
|
||||
|
||||
- name: Set Matrix Group UID Variable
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
matrix_user_uid: "{{ matrix_user.uid }}"
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# For running with another webserver, we recommend being part of the `matrix` group.
|
||||
- name: Ensure Matrix static-files path exists
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
@ -14,24 +14,39 @@
|
||||
- "{{ matrix_static_files_base_path }}/.well-known/matrix"
|
||||
|
||||
- name: Ensure Matrix /.well-known/matrix/client file configured
|
||||
copy:
|
||||
content: "{{ matrix_well_known_matrix_client_configuration|to_nice_json }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_well_known_matrix_client_configuration | to_nice_json }}"
|
||||
dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/client"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure Matrix /.well-known/matrix/server file configured
|
||||
copy:
|
||||
content: "{{ matrix_well_known_matrix_server_configuration|to_nice_json }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_well_known_matrix_server_configuration | to_nice_json }}"
|
||||
dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/server"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
when: matrix_well_known_matrix_server_enabled|bool
|
||||
when: matrix_well_known_matrix_server_enabled | bool
|
||||
|
||||
- name: Ensure Matrix /.well-known/matrix/server file deleted
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_static_files_base_path }}/.well-known/matrix/server"
|
||||
state: absent
|
||||
when: "not matrix_well_known_matrix_server_enabled|bool"
|
||||
when: "not matrix_well_known_matrix_server_enabled | bool"
|
||||
|
||||
- name: Ensure Matrix /.well-known/matrix/support file configured
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_well_known_matrix_support_configuration | to_nice_json }}"
|
||||
dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/support"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
when: matrix_well_known_matrix_support_enabled | bool
|
||||
|
||||
- name: Ensure Matrix /.well-known/matrix/support file deleted
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_static_files_base_path }}/.well-known/matrix/support"
|
||||
state: absent
|
||||
when: "not matrix_well_known_matrix_support_enabled | bool"
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
# This is for both RedHat 7 and 8
|
||||
- name: Ensure fuse installed (RedHat)
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- fuse
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
# This is for both Debian and Raspbian
|
||||
- name: Ensure fuse installed (Debian/Raspbian)
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- fuse
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Ensure fuse installed (Archlinux)
|
||||
pacman:
|
||||
name:
|
||||
- fuse3
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_distribution == 'Archlinux'
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
# This is for both RedHat 7 and 8
|
||||
- name: Ensure openssl installed (RedHat)
|
||||
yum:
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- openssl
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
# This is for both Debian and Raspbian
|
||||
- name: Ensure openssl installed (Debian/Raspbian)
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- openssl
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Ensure openssl installed (Archlinux)
|
||||
pacman:
|
||||
name:
|
||||
- openssl
|
||||
state: latest
|
||||
state: present
|
||||
when: ansible_distribution == 'Archlinux'
|
||||
|
@ -0,0 +1,7 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
{
|
||||
"admins": {{ matrix_homeserver_admin_contacts|to_json }}
|
||||
{% if matrix_homeserver_support_url %},
|
||||
"support_page": {{ matrix_homeserver_support_url|to_json }}
|
||||
{% endif %}
|
||||
}
|
118
roles/matrix-bot-buscarron/defaults/main.yml
Normal file
118
roles/matrix-bot-buscarron/defaults/main.yml
Normal file
@ -0,0 +1,118 @@
|
||||
---
|
||||
# buscarron is a helpdesk bot
|
||||
# Project source code URL: https://gitlab.com/etke.cc/buscarron
|
||||
|
||||
matrix_bot_buscarron_enabled: true
|
||||
|
||||
matrix_bot_buscarron_container_image_self_build: false
|
||||
matrix_bot_buscarron_docker_repo: "https://gitlab.com/etke.cc/buscarron.git"
|
||||
matrix_bot_buscarron_docker_repo_version: "{{ matrix_bot_buscarron_version }}"
|
||||
matrix_bot_buscarron_docker_src_files_path: "{{ matrix_base_data_path }}/buscarron/docker-src"
|
||||
|
||||
matrix_bot_buscarron_version: v1.2.0
|
||||
matrix_bot_buscarron_docker_image: "{{ matrix_bot_buscarron_docker_image_name_prefix }}buscarron:{{ matrix_bot_buscarron_version }}"
|
||||
matrix_bot_buscarron_docker_image_name_prefix: "{{ 'localhost/' if matrix_bot_buscarron_container_image_self_build else 'registry.gitlab.com/etke.cc/' }}"
|
||||
matrix_bot_buscarron_docker_image_force_pull: "{{ matrix_bot_buscarron_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_bot_buscarron_base_path: "{{ matrix_base_data_path }}/buscarron"
|
||||
matrix_bot_buscarron_config_path: "{{ matrix_bot_buscarron_base_path }}/config"
|
||||
matrix_bot_buscarron_data_path: "{{ matrix_bot_buscarron_base_path }}/data"
|
||||
matrix_bot_buscarron_data_store_path: "{{ matrix_bot_buscarron_data_path }}/store"
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_bot_buscarron_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-bot-buscarron.service depends on
|
||||
matrix_bot_buscarron_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# List of systemd services that matrix-bot-buscarron.service wants
|
||||
matrix_bot_buscarron_systemd_wanted_services_list: []
|
||||
|
||||
|
||||
# Database-related configuration fields.
|
||||
#
|
||||
# To use SQLite, stick to these defaults.
|
||||
#
|
||||
# To use Postgres:
|
||||
# - change the engine (`matrix_bot_buscarron_database_engine: 'postgres'`)
|
||||
# - adjust your database credentials via the `matrix_bot_buscarron_database_*` variables
|
||||
matrix_bot_buscarron_database_engine: 'sqlite'
|
||||
|
||||
matrix_bot_buscarron_sqlite_database_path_local: "{{ matrix_bot_buscarron_data_path }}/bot.db"
|
||||
matrix_bot_buscarron_sqlite_database_path_in_container: "/data/bot.db"
|
||||
|
||||
matrix_bot_buscarron_database_username: 'buscarron'
|
||||
matrix_bot_buscarron_database_password: 'some-password'
|
||||
matrix_bot_buscarron_database_hostname: 'matrix-postgres'
|
||||
matrix_bot_buscarron_database_port: 5432
|
||||
matrix_bot_buscarron_database_name: 'buscarron'
|
||||
|
||||
matrix_bot_buscarron_database_connection_string: 'postgres://{{ matrix_bot_buscarron_database_username }}:{{ matrix_bot_buscarron_database_password }}@{{ matrix_bot_buscarron_database_hostname }}:{{ matrix_bot_buscarron_database_port }}/{{ matrix_bot_buscarron_database_name }}?sslmode=disable'
|
||||
|
||||
matrix_bot_buscarron_storage_database: "{{
|
||||
{
|
||||
'sqlite': matrix_bot_buscarron_sqlite_database_path_in_container,
|
||||
'postgres': matrix_bot_buscarron_database_connection_string,
|
||||
}[matrix_bot_buscarron_database_engine]
|
||||
}}"
|
||||
|
||||
matrix_bot_buscarron_database_dialect: "{{
|
||||
{
|
||||
'sqlite': 'sqlite3',
|
||||
'postgres': 'postgres',
|
||||
}[matrix_bot_buscarron_database_engine]
|
||||
}}"
|
||||
|
||||
|
||||
# The bot's username. This user needs to be created manually beforehand.
|
||||
# Also see `matrix_bot_buscarron_password`.
|
||||
matrix_bot_buscarron_login: "bot.buscarron"
|
||||
|
||||
# The password that the bot uses to authenticate.
|
||||
matrix_bot_buscarron_password: ''
|
||||
|
||||
# the homeserver URL, uses internal synapse container address by default
|
||||
matrix_bot_buscarron_homeserver: "{{ matrix_homeserver_container_url }}"
|
||||
|
||||
# forms configuration
|
||||
matrix_bot_buscarron_forms: []
|
||||
|
||||
# Disable encryption
|
||||
matrix_bot_buscarron_noencryption:
|
||||
|
||||
# Sentry DSN
|
||||
matrix_bot_buscarron_sentry:
|
||||
|
||||
# Log level
|
||||
matrix_bot_buscarron_loglevel: INFO
|
||||
|
||||
# spam hosts/domains
|
||||
matrix_bot_buscarron_spam_hosts: []
|
||||
|
||||
# spam email addresses
|
||||
matrix_bot_buscarron_spam_emails: []
|
||||
|
||||
# spam email localparts
|
||||
matrix_bot_buscarron_spam_localparts: []
|
||||
|
||||
# Ban duration in hours
|
||||
matrix_bot_buscarron_ban_duration: 24
|
||||
|
||||
# Banlist size
|
||||
matrix_bot_buscarron_ban_size: 10000
|
||||
|
||||
# Postmark token (confirmation emails)
|
||||
matrix_bot_buscarron_pm_token:
|
||||
|
||||
# Postmark sender signature
|
||||
matrix_bot_buscarron_pm_from:
|
||||
|
||||
# Postmark confirmation email's reply-to
|
||||
matrix_bot_buscarron_pm_replyto:
|
||||
|
||||
# Additional environment variables to pass to the buscarron container
|
||||
#
|
||||
# Example:
|
||||
# matrix_bot_buscarron_environment_variables_extension: |
|
||||
# BUSCARRON_LOGLEVEL=DEBUG
|
||||
matrix_bot_buscarron_environment_variables_extension: ''
|
5
roles/matrix-bot-buscarron/tasks/init.yml
Normal file
5
roles/matrix-bot-buscarron/tasks/init.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-buscarron.service'] }}"
|
||||
when: matrix_bot_buscarron_enabled | bool
|
23
roles/matrix-bot-buscarron/tasks/main.yml
Normal file
23
roles/matrix-bot-buscarron/tasks/main.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_buscarron_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-buscarron
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_buscarron_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-buscarron
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_buscarron_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-buscarron
|
103
roles/matrix-bot-buscarron/tasks/setup_install.yml
Normal file
103
roles/matrix-bot-buscarron/tasks/setup_install.yml
Normal file
@ -0,0 +1,103 @@
|
||||
---
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_buscarron_requires_restart: false
|
||||
|
||||
- block:
|
||||
- name: Check if an SQLite database already exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
|
||||
register: matrix_bot_buscarron_sqlite_database_path_local_stat_result
|
||||
|
||||
- block:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_postgres_db_migration_request:
|
||||
src: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_bot_buscarron_database_connection_string }}"
|
||||
caller: "{{ role_path | basename }}"
|
||||
engine_variable_name: 'matrix_bot_buscarron_database_engine'
|
||||
engine_old: 'sqlite'
|
||||
systemd_services_to_stop: ['matrix-bot-buscarron.service']
|
||||
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: migrate_db_to_postgres
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_buscarron_requires_restart: true
|
||||
when: "matrix_bot_buscarron_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
when: "matrix_bot_buscarron_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure buscarron paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_bot_buscarron_config_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_buscarron_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_buscarron_data_store_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_buscarron_docker_src_files_path }}", when: true}
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure buscarron environment variables file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/env.j2"
|
||||
dest: "{{ matrix_bot_buscarron_config_path }}/env"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure buscarron image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_buscarron_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_buscarron_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_buscarron_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_buscarron_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure buscarron repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_buscarron_docker_repo }}"
|
||||
version: "{{ matrix_bot_buscarron_docker_repo_version }}"
|
||||
dest: "{{ matrix_bot_buscarron_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_buscarron_git_pull_results
|
||||
when: "matrix_bot_buscarron_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure buscarron image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_buscarron_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_bot_buscarron_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_buscarron_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_buscarron_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-bot-buscarron.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_buscarron_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-buscarron.service installation
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_buscarron_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-buscarron.service restarted, if necessary
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-buscarron.service"
|
||||
state: restarted
|
||||
when: "matrix_bot_buscarron_requires_restart | bool"
|
36
roles/matrix-bot-buscarron/tasks/setup_uninstall.yml
Normal file
36
roles/matrix-bot-buscarron/tasks/setup_uninstall.yml
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-buscarron service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
|
||||
register: matrix_bot_buscarron_service_stat
|
||||
|
||||
- name: Ensure matrix-buscarron is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-buscarron
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-buscarron.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
|
||||
state: absent
|
||||
when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-buscarron.service removal
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix buscarron paths don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_buscarron_base_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Ensure buscarron Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_buscarron_docker_image }}"
|
||||
state: absent
|
@ -1,10 +1,9 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_mx_puppet_skype_appservice_token"
|
||||
- "matrix_mx_puppet_skype_homeserver_token"
|
||||
- "matrix_bot_buscarron_password"
|
29
roles/matrix-bot-buscarron/templates/env.j2
Normal file
29
roles/matrix-bot-buscarron/templates/env.j2
Normal file
@ -0,0 +1,29 @@
|
||||
BUSCARRON_LOGIN={{ matrix_bot_buscarron_login }}
|
||||
BUSCARRON_PASSWORD={{ matrix_bot_buscarron_password }}
|
||||
BUSCARRON_HOMESERVER={{ matrix_bot_buscarron_homeserver }}
|
||||
BUSCARRON_DB_DSN={{ matrix_bot_buscarron_database_connection_string }}
|
||||
BUSCARRON_DB_DIALECT={{ matrix_bot_buscarron_database_dialect }}
|
||||
BUSCARRON_SPAM_HOSTS={{ matrix_bot_buscarron_spam_hosts|join(" ") }}
|
||||
BUSCARRON_SPAM_EMAILS={{ matrix_bot_buscarron_spam_emails|join(" ") }}
|
||||
BUSCARRON_SPAM_LOCALPARTS={{ matrix_bot_buscarron_spam_localparts|join(" ") }}
|
||||
BUSCARRON_SENTRY={{ matrix_bot_buscarron_sentry }}
|
||||
BUSCARRON_LOGLEVEL={{ matrix_bot_buscarron_loglevel }}
|
||||
BUSCARRON_BAN_DURATION={{ matrix_bot_buscarron_ban_duration }}
|
||||
BUSCARRON_BAN_SIZE={{ matrix_bot_buscarron_ban_size }}
|
||||
BUSCARRON_PM_TOKEN={{ matrix_bot_buscarron_pm_token }}
|
||||
BUSCARRON_PM_FROM={{ matrix_bot_buscarron_pm_from }}
|
||||
BUSCARRON_PM_REPLYTO={{ matrix_bot_buscarron_pm_replyto }}
|
||||
BUSCARRON_NOENCRYPTION={{ matrix_bot_buscarron_noencryption }}
|
||||
{% set forms = [] %}
|
||||
{% for form in matrix_bot_buscarron_forms -%}{{- forms.append(form.name) -}}
|
||||
BUSCARRON_{{ form.name|upper }}_ROOM={{ form.room|default('') }}
|
||||
BUSCARRON_{{ form.name|upper }}_REDIRECT={{ form.redirect|default('') }}
|
||||
BUSCARRON_{{ form.name|upper }}_HASDOMAIN={{ form.hasdomain|default('') }}
|
||||
BUSCARRON_{{ form.name|upper }}_RATELIMIT={{ form.ratelimit|default('') }}
|
||||
BUSCARRON_{{ form.name|upper }}_EXTENSIONS={{ form.extensions|default('')|join(' ') }}
|
||||
BUSCARRON_{{ form.name|upper }}_CONFIRMATION_SUBJECT={{ form.confirmation_subject|default('') }}
|
||||
BUSCARRON_{{ form.name|upper }}_CONFIRMATION_BODY={{ form.confirmation_body|default('') }}
|
||||
{% endfor %}
|
||||
BUSCARRON_LIST={{ forms|join(" ") }}
|
||||
|
||||
{{ matrix_bot_buscarron_environment_variables_extension }}
|
@ -0,0 +1,39 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix web forms bot
|
||||
{% for service in matrix_bot_buscarron_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_bot_buscarron_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ matrix_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-buscarron 2>/dev/null || true'
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-buscarron 2>/dev/null || true'
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-buscarron \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--read-only \
|
||||
--network={{ matrix_docker_network }} \
|
||||
--env-file={{ matrix_bot_buscarron_config_path }}/env \
|
||||
--mount type=bind,src={{ matrix_bot_buscarron_data_path }},dst=/data \
|
||||
{% for arg in matrix_bot_buscarron_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_bot_buscarron_docker_image }}
|
||||
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-buscarron 2>/dev/null || true'
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-buscarron 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-bot-buscarron
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
# Go-NEB is a Matrix bot written in Go. It is the successor to Matrix-NEB, the original Matrix bot written in Python.
|
||||
# See: https://github.com/matrix-org/go-neb
|
||||
# Project source code URL: https://github.com/matrix-org/go-neb
|
||||
|
||||
matrix_bot_go_neb_enabled: true
|
||||
matrix_bot_go_neb_version: latest
|
||||
@ -224,8 +224,8 @@ matrix_bot_go_neb_configuration_extension_yaml: |
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_bot_go_neb_configuration_yaml`.
|
||||
|
||||
matrix_bot_go_neb_configuration_extension: "{{ matrix_bot_go_neb_configuration_extension_yaml|from_yaml if matrix_bot_go_neb_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_bot_go_neb_configuration_extension: "{{ matrix_bot_go_neb_configuration_extension_yaml | from_yaml if matrix_bot_go_neb_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
# Holds the final configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_bot_go_neb_configuration_yaml`.
|
||||
matrix_bot_go_neb_configuration: "{{ matrix_bot_go_neb_configuration_yaml|from_yaml|combine(matrix_bot_go_neb_configuration_extension, recursive=True) }}"
|
||||
matrix_bot_go_neb_configuration: "{{ matrix_bot_go_neb_configuration_yaml | from_yaml | combine(matrix_bot_go_neb_configuration_extension, recursive=True) }}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-go-neb.service'] }}"
|
||||
when: matrix_bot_go_neb_enabled|bool
|
||||
when: matrix_bot_go_neb_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_bot_go_neb_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_go_neb_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-go-neb
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_bot_go_neb_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_go_neb_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-go-neb
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_bot_go_neb_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_go_neb_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-go-neb
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_go_neb_requires_restart: false
|
||||
|
||||
- name: Ensure go-neb paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -14,7 +14,7 @@
|
||||
- {path: "{{ matrix_bot_go_neb_config_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_go_neb_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_go_neb_data_store_path }}", when: true}
|
||||
when: "item.when|bool"
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure go-neb image is pulled
|
||||
docker_image:
|
||||
@ -28,27 +28,27 @@
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure go-neb config installed
|
||||
copy:
|
||||
content: "{{ matrix_bot_go_neb_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_bot_go_neb_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_bot_go_neb_config_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-bot-go-neb.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-go-neb.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_go_neb_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-go-neb.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_go_neb_systemd_service_result.changed|bool"
|
||||
when: "matrix_bot_go_neb_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-go-neb.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-go-neb.service"
|
||||
state: restarted
|
||||
when: "matrix_bot_go_neb_requires_restart|bool"
|
||||
when: "matrix_bot_go_neb_requires_restart | bool"
|
||||
|
@ -1,32 +1,32 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-go-neb service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
|
||||
register: matrix_bot_go_neb_service_stat
|
||||
|
||||
- name: Ensure matrix-go-neb is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-go-neb
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-go-neb.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
|
||||
state: absent
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-go-neb.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_go_neb_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix go-neb paths don't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_go_neb_base_path }}"
|
||||
state: absent
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
---
|
||||
|
||||
- name: Fail if there's not at least 1 client
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need at least 1 client in the matrix_bot_go_neb_clients block.
|
||||
when: matrix_bot_go_neb_clients is not defined or matrix_bot_go_neb_clients[0] is not defined
|
||||
|
||||
- name: Fail if there's not at least 1 service
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need at least 1 service in the matrix_bot_go_neb_services block.
|
||||
when: matrix_bot_go_neb_services is not defined or matrix_bot_go_neb_services[0] is not defined
|
||||
|
@ -1,14 +1,15 @@
|
||||
---
|
||||
# honoroit is a helpdesk bot
|
||||
# See: https://gitlab.com/etke.cc/honoroit
|
||||
# Project source code URL: https://gitlab.com/etke.cc/honoroit
|
||||
|
||||
matrix_bot_honoroit_enabled: true
|
||||
|
||||
matrix_bot_honoroit_container_image_self_build: false
|
||||
matrix_bot_honoroit_docker_repo: "https://gitlab.com/etke.cc/honoroit.git"
|
||||
matrix_bot_honoroit_docker_repo_version: "{{ matrix_bot_honoroit_version }}"
|
||||
matrix_bot_honoroit_docker_src_files_path: "{{ matrix_base_data_path }}/honoroit/docker-src"
|
||||
|
||||
matrix_bot_honoroit_version: v0.9.7
|
||||
matrix_bot_honoroit_version: v0.9.12
|
||||
matrix_bot_honoroit_docker_image: "{{ matrix_bot_honoroit_docker_image_name_prefix }}honoroit:{{ matrix_bot_honoroit_version }}"
|
||||
matrix_bot_honoroit_docker_image_name_prefix: "{{ 'localhost/' if matrix_bot_honoroit_container_image_self_build else 'registry.gitlab.com/etke.cc/' }}"
|
||||
matrix_bot_honoroit_docker_image_force_pull: "{{ matrix_bot_honoroit_docker_image.endswith(':latest') }}"
|
||||
@ -84,15 +85,27 @@ matrix_bot_honoroit_sentry: ''
|
||||
# Log level
|
||||
matrix_bot_honoroit_loglevel: ''
|
||||
|
||||
# Disable encryption
|
||||
matrix_bot_honoroit_noencryption: false
|
||||
|
||||
# Max items in cache
|
||||
matrix_bot_honoroit_cachesize: ''
|
||||
|
||||
# List of ignored room IDs
|
||||
matrix_bot_honoroit_ignoredrooms: []
|
||||
|
||||
# Ignore messages outside of threads
|
||||
matrix_bot_honoroit_ignorenothread: false
|
||||
|
||||
# Text prefix: open
|
||||
matrix_bot_honoroit_text_prefix_open: ''
|
||||
|
||||
# Text prefix: done
|
||||
matrix_bot_honoroit_text_prefix_done: ''
|
||||
|
||||
# Text: no encryption
|
||||
matrix_bot_honoroit_text_noencryption: ''
|
||||
|
||||
# Text: greetings
|
||||
matrix_bot_honoroit_text_greetings: ''
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-honoroit.service'] }}"
|
||||
when: matrix_bot_honoroit_enabled|bool
|
||||
when: matrix_bot_honoroit_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_bot_honoroit_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_honoroit_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-honoroit
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_bot_honoroit_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_honoroit_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-honoroit
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_bot_honoroit_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_honoroit_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-honoroit
|
||||
|
@ -1,32 +1,34 @@
|
||||
---
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_honoroit_requires_restart: false
|
||||
|
||||
- block:
|
||||
- name: Check if an SQLite database already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
|
||||
register: matrix_bot_honoroit_sqlite_database_path_local_stat_result
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_postgres_db_migration_request:
|
||||
src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_bot_honoroit_database_connection_string }}"
|
||||
caller: "{{ role_path|basename }}"
|
||||
caller: "{{ role_path | basename }}"
|
||||
engine_variable_name: 'matrix_bot_honoroit_database_engine'
|
||||
engine_old: 'sqlite'
|
||||
systemd_services_to_stop: ['matrix-bot-honoroit.service']
|
||||
|
||||
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: migrate_db_to_postgres
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_honoroit_requires_restart: true
|
||||
when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists|bool"
|
||||
when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
when: "matrix_bot_honoroit_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure honoroit paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -37,10 +39,10 @@
|
||||
- {path: "{{ matrix_bot_honoroit_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_honoroit_docker_src_files_path }}", when: true}
|
||||
when: "item.when|bool"
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure honoroit environment variables file created
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/env.j2"
|
||||
dest: "{{ matrix_bot_honoroit_config_path }}/env"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
@ -53,21 +55,22 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_honoroit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_honoroit_container_image_self_build|bool"
|
||||
when: "not matrix_bot_honoroit_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure honoroit repository is present on self-build
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_honoroit_docker_repo }}"
|
||||
version: "{{ matrix_bot_honoroit_docker_repo_version }}"
|
||||
dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_honoroit_git_pull_results
|
||||
when: "matrix_bot_honoroit_container_image_self_build|bool"
|
||||
when: "matrix_bot_honoroit_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure honoroit image is built
|
||||
docker_image:
|
||||
@ -79,22 +82,22 @@
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_honoroit_container_image_self_build|bool"
|
||||
when: "matrix_bot_honoroit_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-bot-honoroit.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_honoroit_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-honoroit.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_honoroit_systemd_service_result.changed|bool"
|
||||
when: "matrix_bot_honoroit_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-honoroit.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-honoroit.service"
|
||||
state: restarted
|
||||
when: "matrix_bot_honoroit_requires_restart|bool"
|
||||
when: "matrix_bot_honoroit_requires_restart | bool"
|
||||
|
@ -1,32 +1,32 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-honoroit service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
|
||||
register: matrix_bot_honoroit_service_stat
|
||||
|
||||
- name: Ensure matrix-honoroit is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-honoroit
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-honoroit.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
|
||||
state: absent
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-honoroit.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_honoroit_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix honoroit paths don't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_honoroit_base_path }}"
|
||||
state: absent
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
|
@ -8,8 +8,12 @@ HONOROIT_PREFIX={{ matrix_bot_honoroit_prefix }}
|
||||
HONOROIT_SENTRY={{ matrix_bot_honoroit_sentry }}
|
||||
HONOROIT_LOGLEVEL={{ matrix_bot_honoroit_loglevel }}
|
||||
HONOROIT_CACHESIZE={{ matrix_bot_honoroit_cachesize }}
|
||||
HONOROIT_NOENCRYPTION={{ matrix_bot_honoroit_noencryption }}
|
||||
HONOROIT_IGNORENOTHREAD={{ matrix_bot_honoroit_ignorenothread }}
|
||||
HONOROIT_IGNOREDROOMS={{ matrix_bot_honoroit_ignoredrooms|join(' ') }}
|
||||
HONOROIT_TEXT_PREFIX_OPEN={{ matrix_bot_honoroit_text_prefix_open }}
|
||||
HONOROIT_TEXT_PREFIX_DONE={{ matrix_bot_honoroit_text_prefix_done }}
|
||||
HONOROIT_TEXT_NOENCRYPTION={{ matrix_bot_honoroit_text_noencryption }}
|
||||
HONOROIT_TEXT_GREETINGS={{ matrix_bot_honoroit_text_greetings }}
|
||||
HONOROIT_TEXT_INVITE={{ matrix_bot_honoroit_text_invite }}
|
||||
HONOROIT_TEXT_JOIN={{ matrix_bot_honoroit_text_join }}
|
||||
|
50
roles/matrix-bot-matrix-registration-bot/defaults/main.yml
Normal file
50
roles/matrix-bot-matrix-registration-bot/defaults/main.yml
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
# matrix-registration-bot creates and manages registration tokens for a matrix server
|
||||
# Project source code URL: https://github.com/moan0s/matrix-registration-bot
|
||||
|
||||
matrix_bot_matrix_registration_bot_enabled: true
|
||||
matrix_bot_matrix_registration_bot_container_image_self_build: false
|
||||
matrix_bot_matrix_registration_bot_docker_repo: "https://github.com/moan0s/matrix-registration-bot.git"
|
||||
matrix_bot_matrix_registration_bot_docker_repo_version: "{{ matrix_bot_matrix_registration_bot_version if matrix_bot_matrix_registration_bot_version != 'latest' else 'main' }}"
|
||||
matrix_bot_matrix_registration_bot_docker_src_files_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/docker-src"
|
||||
|
||||
matrix_bot_matrix_registration_bot_version: latest
|
||||
matrix_bot_matrix_registration_bot_docker_image: "{{ matrix_container_global_registry_prefix }}moanos/matrix-registration-bot:{{ matrix_bot_matrix_registration_bot_version }}"
|
||||
matrix_bot_matrix_registration_bot_docker_image_force_pull: "{{ matrix_bot_matrix_registration_bot_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_bot_matrix_registration_bot_base_path: "{{ matrix_base_data_path }}/matrix-registration-bot"
|
||||
matrix_bot_matrix_registration_bot_config_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/config"
|
||||
matrix_bot_matrix_registration_bot_data_path: "{{ matrix_bot_matrix_registration_bot_base_path }}/data"
|
||||
|
||||
matrix_bot_matrix_registration_bot_bot_server: "https://{{ matrix_server_fqn_matrix }}"
|
||||
matrix_bot_matrix_registration_bot_api_base_url: "https://{{ matrix_server_fqn_matrix }}"
|
||||
|
||||
# The access token that the bot uses to communicate in Matrix chats
|
||||
# This does not necessarily need to be a privileged (admin) access token.
|
||||
matrix_bot_matrix_registration_bot_bot_access_token: ''
|
||||
|
||||
# The access token that the bot uses to call the Matrix API for creating registration tokens.
|
||||
# This needs to be a privileged (admin) access token.
|
||||
# By default, we assume `matrix_bot_matrix_registration_bot_bot_access_token` is such a privileged token and we use it as is.
|
||||
# If necessary, you can define your own other access token here, which might even be for a different Matrix user.
|
||||
matrix_bot_matrix_registration_bot_api_token: "{{ matrix_bot_matrix_registration_bot_bot_access_token }}"
|
||||
|
||||
matrix_bot_matrix_registration_bot_logging_level: info
|
||||
matrix_bot_matrix_registration_environment_variables_extension: ''
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_bot_matrix_registration_bot_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-bot-matrix-registration-bot.service depends on
|
||||
matrix_bot_matrix_registration_bot_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# List of systemd services that matrix-bot-matrix-registration-bot.service wants
|
||||
matrix_bot_matrix_registration_bot_systemd_wanted_services_list: []
|
||||
|
||||
# The bot's username. This user needs to be created manually beforehand.
|
||||
# Also see `matrix_bot_matrix_registration_bot_user_password`.
|
||||
matrix_bot_matrix_registration_bot_matrix_user_id_localpart: "bot.matrix-registration-bot"
|
||||
|
||||
matrix_bot_matrix_registration_bot_matrix_user_id: '@{{ matrix_bot_matrix_registration_bot_matrix_user_id_localpart }}:{{ matrix_domain }}'
|
||||
|
||||
matrix_bot_matrix_registration_bot_matrix_homeserver_url: "{{ matrix_homeserver_container_url }}"
|
5
roles/matrix-bot-matrix-registration-bot/tasks/init.yml
Normal file
5
roles/matrix-bot-matrix-registration-bot/tasks/init.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-registration-bot.service'] }}"
|
||||
when: matrix_bot_matrix_registration_bot_enabled | bool
|
23
roles/matrix-bot-matrix-registration-bot/tasks/main.yml
Normal file
23
roles/matrix-bot-matrix-registration-bot/tasks/main.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-registration-bot
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-registration-bot
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_matrix_registration_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-registration-bot
|
@ -0,0 +1,74 @@
|
||||
---
|
||||
|
||||
- name: Ensure matrix-registration-bot paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_bot_matrix_registration_bot_config_path }}", when: true}
|
||||
- - {path: "{{ matrix_bot_matrix_registration_bot_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}", when: true}
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure matrix-registration-bot configuration file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/config/config.yml.j2"
|
||||
dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yml"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: 0640
|
||||
|
||||
- name: Ensure matrix-registration-bot image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_matrix_registration_bot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_matrix_registration_bot_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_matrix_registration_bot_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-registration-bot repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_matrix_registration_bot_docker_repo }}"
|
||||
version: "{{ matrix_bot_matrix_registration_bot_docker_repo_version }}"
|
||||
dest: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_matrix_registration_bot_git_pull_results
|
||||
when: "matrix_bot_matrix_registration_bot_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-registration-bot image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_bot_matrix_registration_bot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_matrix_registration_bot_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-registration-bot.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_matrix_registration_bot_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service installation
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_matrix_registration_bot_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-registration-bot.service restarted, if necessary
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-matrix-registration-bot.service"
|
||||
state: restarted
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-matrix-registration-bot service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
|
||||
register: matrix_bot_matrix_registration_bot_service_stat
|
||||
|
||||
- name: Ensure matrix-matrix-registration-bot is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-matrix-registration-bot
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-registration-bot.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
|
||||
state: absent
|
||||
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service removal
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix matrix-registration-bot paths don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_matrix_registration_bot_base_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Ensure matrix-registration-bot Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
|
||||
state: absent
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_bot_matrix_registration_bot_bot_access_token"
|
||||
- "matrix_bot_matrix_registration_bot_api_token"
|
@ -0,0 +1,12 @@
|
||||
bot:
|
||||
server: {{ matrix_bot_matrix_registration_bot_bot_server|to_json }}
|
||||
username: {{ matrix_bot_matrix_registration_bot_matrix_user_id_localpart|to_json }}
|
||||
access_token: {{ matrix_bot_matrix_registration_bot_bot_access_token|to_json }}
|
||||
api:
|
||||
# API endpoint of the registration tokens
|
||||
base_url: {{ matrix_bot_matrix_registration_bot_api_base_url|to_json }}
|
||||
# Access token of an administrator on the server
|
||||
token: {{ matrix_bot_matrix_registration_bot_api_token|to_json }}
|
||||
logging:
|
||||
level: {{ matrix_bot_matrix_registration_bot_logging_level|to_json }}
|
||||
|
@ -0,0 +1,37 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix registration bot
|
||||
{% for service in matrix_bot_matrix_registration_bot_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_bot_matrix_registration_bot_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ matrix_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-registration-bot 2>/dev/null || true'
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true'
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-matrix-registration-bot \
|
||||
--log-driver=none \
|
||||
--cap-drop=ALL \
|
||||
-e "CONFIG_PATH=/config/config.yml" \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--read-only \
|
||||
--mount type=bind,src={{ matrix_bot_matrix_registration_bot_config_path }},dst=/config,ro \
|
||||
--mount type=bind,src={{ matrix_bot_matrix_registration_bot_data_path }},dst=/data \
|
||||
--network={{ matrix_docker_network }} \
|
||||
{{ matrix_bot_matrix_registration_bot_docker_image }}
|
||||
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-registration-bot 2>/dev/null || true'
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-bot-matrix-registration-bot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,11 +1,12 @@
|
||||
---
|
||||
# matrix-reminder-bot is a bot for one-off and recurring reminders
|
||||
# See: https://github.com/anoadragon453/matrix-reminder-bot
|
||||
# Project source code URL: https://github.com/anoadragon453/matrix-reminder-bot
|
||||
|
||||
matrix_bot_matrix_reminder_bot_enabled: true
|
||||
|
||||
matrix_bot_matrix_reminder_bot_container_image_self_build: false
|
||||
matrix_bot_matrix_reminder_bot_docker_repo: "https://github.com/anoadragon453/matrix-reminder-bot.git"
|
||||
matrix_bot_matrix_reminder_bot_docker_repo_version: "{{ matrix_bot_matrix_reminder_bot_version }}"
|
||||
matrix_bot_matrix_reminder_bot_docker_src_files_path: "{{ matrix_base_data_path }}/matrix-reminder-bot/docker-src"
|
||||
|
||||
matrix_bot_matrix_reminder_bot_version: release-v0.2.1
|
||||
@ -17,6 +18,8 @@ matrix_bot_matrix_reminder_bot_config_path: "{{ matrix_bot_matrix_reminder_bot_b
|
||||
matrix_bot_matrix_reminder_bot_data_path: "{{ matrix_bot_matrix_reminder_bot_base_path }}/data"
|
||||
matrix_bot_matrix_reminder_bot_data_store_path: "{{ matrix_bot_matrix_reminder_bot_data_path }}/store"
|
||||
|
||||
matrix_bot_matrix_reminder_bot_command_prefix: "!"
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_bot_matrix_reminder_bot_container_extra_arguments: []
|
||||
|
||||
@ -91,8 +94,8 @@ matrix_bot_matrix_reminder_bot_configuration_extension_yaml: |
|
||||
# matrix:
|
||||
# device_name: My-Reminder-Bot
|
||||
|
||||
matrix_bot_matrix_reminder_bot_configuration_extension: "{{ matrix_bot_matrix_reminder_bot_configuration_extension_yaml|from_yaml if matrix_bot_matrix_reminder_bot_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_bot_matrix_reminder_bot_configuration_extension: "{{ matrix_bot_matrix_reminder_bot_configuration_extension_yaml | from_yaml if matrix_bot_matrix_reminder_bot_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
# Holds the final configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_bot_matrix_reminder_bot_configuration_yaml`.
|
||||
matrix_bot_matrix_reminder_bot_configuration: "{{ matrix_bot_matrix_reminder_bot_configuration_yaml|from_yaml|combine(matrix_bot_matrix_reminder_bot_configuration_extension, recursive=True) }}"
|
||||
matrix_bot_matrix_reminder_bot_configuration: "{{ matrix_bot_matrix_reminder_bot_configuration_yaml | from_yaml | combine(matrix_bot_matrix_reminder_bot_configuration_extension, recursive=True) }}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-reminder-bot.service'] }}"
|
||||
when: matrix_bot_matrix_reminder_bot_enabled|bool
|
||||
when: matrix_bot_matrix_reminder_bot_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_bot_matrix_reminder_bot_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-reminder-bot
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_bot_matrix_reminder_bot_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-reminder-bot
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_bot_matrix_reminder_bot_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_matrix_reminder_bot_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-matrix-reminder-bot
|
||||
|
@ -1,33 +1,35 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_matrix_reminder_bot_requires_restart: false
|
||||
|
||||
- block:
|
||||
- name: Check if an SQLite database already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}"
|
||||
register: matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_postgres_db_migration_request:
|
||||
src: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_bot_matrix_reminder_bot_database_connection_string }}"
|
||||
caller: "{{ role_path|basename }}"
|
||||
caller: "{{ role_path | basename }}"
|
||||
engine_variable_name: 'matrix_bot_matrix_reminder_bot_database_engine'
|
||||
engine_old: 'sqlite'
|
||||
systemd_services_to_stop: ['matrix-bot-matrix-reminder-bot.service']
|
||||
|
||||
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: migrate_db_to_postgres
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_matrix_reminder_bot_requires_restart: true
|
||||
when: "matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result.stat.exists|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure matrix-reminder-bot paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -38,7 +40,7 @@
|
||||
- {path: "{{ matrix_bot_matrix_reminder_bot_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_matrix_reminder_bot_data_store_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}", when: true}
|
||||
when: "item.when|bool"
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure matrix-reminder-bot image is pulled
|
||||
docker_image:
|
||||
@ -46,21 +48,22 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_matrix_reminder_bot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_matrix_reminder_bot_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_matrix_reminder_bot_container_image_self_build|bool"
|
||||
when: "not matrix_bot_matrix_reminder_bot_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-reminder-bot repository is present on self-build
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_matrix_reminder_bot_docker_repo }}"
|
||||
version: "{{ matrix_bot_matrix_reminder_bot_docker_repo_version }}"
|
||||
dest: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_matrix_reminder_bot_git_pull_results
|
||||
when: "matrix_bot_matrix_reminder_bot_container_image_self_build|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-reminder-bot image is built
|
||||
docker_image:
|
||||
@ -72,30 +75,30 @@
|
||||
dockerfile: docker/Dockerfile
|
||||
path: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_matrix_reminder_bot_container_image_self_build|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-reminder-bot config installed
|
||||
copy:
|
||||
content: "{{ matrix_bot_matrix_reminder_bot_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_bot_matrix_reminder_bot_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_bot_matrix_reminder_bot_config_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-reminder-bot.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-reminder-bot.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_matrix_reminder_bot_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_matrix_reminder_bot_systemd_service_result.changed|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-reminder-bot.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-matrix-reminder-bot.service"
|
||||
state: restarted
|
||||
when: "matrix_bot_matrix_reminder_bot_requires_restart|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_requires_restart | bool"
|
||||
|
@ -1,32 +1,32 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-matrix-reminder-bot service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
|
||||
register: matrix_bot_matrix_reminder_bot_service_stat
|
||||
|
||||
- name: Ensure matrix-matrix-reminder-bot is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-matrix-reminder-bot
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-matrix-reminder-bot.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
|
||||
state: absent
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_matrix_reminder_bot_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure Matrix matrix-reminder-bot paths don't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_matrix_reminder_bot_base_path }}"
|
||||
state: absent
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
@ -10,7 +10,7 @@
|
||||
- "matrix_bot_matrix_reminder_bot_reminders_timezone"
|
||||
|
||||
- name: (Deprecation) Catch and report renamed settings
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
|
||||
|
@ -1,5 +1,5 @@
|
||||
# The string to prefix bot commands with
|
||||
command_prefix: "!"
|
||||
command_prefix: "{{ matrix_bot_matrix_reminder_bot_command_prefix }}"
|
||||
|
||||
# Options for connecting to the bot's Matrix account
|
||||
matrix:
|
||||
|
69
roles/matrix-bot-maubot/defaults/main.yml
Normal file
69
roles/matrix-bot-maubot/defaults/main.yml
Normal file
@ -0,0 +1,69 @@
|
||||
---
|
||||
|
||||
# maubot is a plugin-based Matrix bot system.
|
||||
# Project source code URL: https://mau.dev/maubot/maubot
|
||||
|
||||
matrix_bot_maubot_enabled: true
|
||||
matrix_bot_maubot_container_image_self_build: false
|
||||
matrix_bot_maubot_docker_repo: "https://mau.dev/maubot/maubot.git"
|
||||
matrix_bot_maubot_docker_src_files_path: "{{ matrix_bot_maubot_base_path }}/docker-src"
|
||||
matrix_bot_maubot_docker_repo_version: "{{ 'master' if matrix_bot_maubot_version == 'latest' else matrix_bot_maubot_version }}"
|
||||
|
||||
|
||||
matrix_bot_maubot_version: v0.3.1
|
||||
matrix_bot_maubot_docker_image: "dock.mau.dev/maubot/maubot:{{ matrix_bot_maubot_version }}"
|
||||
matrix_bot_maubot_docker_image_force_pull: "{{ matrix_bot_maubot_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_bot_maubot_base_path: "{{ matrix_base_data_path }}/maubot"
|
||||
matrix_bot_maubot_data_path: "{{ matrix_bot_maubot_base_path }}/data"
|
||||
matrix_bot_maubot_config_path: "{{ matrix_bot_maubot_base_path }}/config"
|
||||
|
||||
matrix_bot_maubot_bot_server_public_url: "https://{{ matrix_server_fqn_matrix }}"
|
||||
matrix_bot_maubot_proxy_management_interface: true
|
||||
|
||||
matrix_bot_maubot_database_engine: sqlite
|
||||
matrix_bot_maubot_sqlite_database_path_local: "{{ matrix_bot_maubot_data_path }}/maubot.db"
|
||||
matrix_bot_maubot_sqlite_database_path_in_container: "/data/maubot.db"
|
||||
|
||||
matrix_bot_maubot_database_username: matrix_bot_maubot
|
||||
matrix_bot_maubot_database_password: ~
|
||||
matrix_bot_maubot_database_hostname: 'matrix-postgres'
|
||||
matrix_bot_maubot_database_port: 5432
|
||||
matrix_bot_maubot_database_name: matrix_bot_maubot
|
||||
|
||||
matrix_bot_maubot_database_connection_string: postgres://{{ matrix_bot_maubot_database_username }}:{{ matrix_bot_maubot_database_password }}@{{ matrix_bot_maubot_database_hostname }}:{{ matrix_bot_maubot_database_port }}/{{ matrix_bot_maubot_database_name }}?sslmode=disable
|
||||
|
||||
matrix_bot_maubot_database_uri: "{{
|
||||
{
|
||||
'sqlite': ('sqlite:///' + matrix_bot_maubot_sqlite_database_path_in_container),
|
||||
'postgres': matrix_bot_maubot_database_connection_string,
|
||||
}[matrix_bot_maubot_database_engine]
|
||||
}}"
|
||||
|
||||
|
||||
# Defines the port number where the management interface is
|
||||
# To actually expose the management interface outside of the container, use `matrix_bot_maubot_management_interface_http_bind_port`
|
||||
matrix_bot_maubot_management_interface_port: 29316
|
||||
|
||||
# Controls whether the maubot container exposes its HTTP management interface port (tcp/29316 in the container).
|
||||
#
|
||||
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:29316"), or empty string to not expose.
|
||||
# If you'll be setting this at all, it should be defined in terms of `matrix_bot_maubot_management_interface_port`.
|
||||
# Example:
|
||||
# matrix_bot_maubot_management_interface_http_bind_port: "127.0.0.1:{{ matrix_bot_maubot_management_interface_port }}"
|
||||
matrix_bot_maubot_management_interface_http_bind_port: ''
|
||||
|
||||
|
||||
matrix_bot_maubot_unshared_secret: 'generate'
|
||||
|
||||
# Specifies the default log level for all bot loggers.
|
||||
matrix_bot_maubot_logging_level: WARNING
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_bot_maubot_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-bot-maubot.service depends on
|
||||
matrix_bot_maubot_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# List of systemd services that matrix-bot-maubot.service wants
|
||||
matrix_bot_maubot_systemd_wanted_services_list: []
|
47
roles/matrix-bot-maubot/tasks/init.yml
Normal file
47
roles/matrix-bot-maubot/tasks/init.yml
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
|
||||
- name: Add maubot to the systemd service list
|
||||
ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-maubot.service'] }}"
|
||||
when: matrix_bot_maubot_enabled | bool
|
||||
|
||||
- name: Configure nginx for maubot
|
||||
block:
|
||||
- name: Generate Maubot proxying configuration for matrix-nginx-proxy
|
||||
ansible.builtin.set_fact:
|
||||
matrix_bot_maubot_matrix_nginx_proxy_configuration: |
|
||||
location ~ ^/(_matrix/maubot/.*) {
|
||||
{% if matrix_nginx_proxy_enabled | default(False) %}
|
||||
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
set $backend "matrix-bot-maubot:{{ matrix_bot_maubot_management_interface_port }}/$1";
|
||||
proxy_pass http://$backend;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
{% else %}
|
||||
{# Generic configuration for use outside of our container setup #}
|
||||
proxy_pass http://127.0.0.1:{{ matrix_bot_maubot_management_interface_port }}/$1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
{% endif %}
|
||||
}
|
||||
when: matrix_bot_maubot_proxy_management_interface | bool
|
||||
|
||||
- name: Register Maubot's proxying configuration with matrix-nginx-proxy
|
||||
ansible.builtin.set_fact:
|
||||
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
|
||||
{{
|
||||
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
|
||||
+
|
||||
[matrix_bot_maubot_matrix_nginx_proxy_configuration]
|
||||
}}
|
||||
when: matrix_bot_maubot_proxy_management_interface|bool
|
||||
|
||||
- name: Warn about reverse-proxying if matrix-nginx-proxy not used
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
NOTE: You've enabled Maubot but are not using the matrix-nginx-proxy
|
||||
reverse proxy.
|
||||
Please make sure that you're proxying the `/_matrix/maubot`
|
||||
URL endpoint to the matrix-maubot container.
|
||||
when: "matrix_bot_maubot_enabled | bool and matrix_bot_maubot_proxy_management_interface | bool and matrix_nginx_proxy_enabled is not defined"
|
@ -5,19 +5,19 @@
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_mx_puppet_skype_enabled|bool"
|
||||
when: "run_setup|bool and matrix_bot_maubot_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-mx-puppet-skype
|
||||
- setup-bot-maubot
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_mx_puppet_skype_enabled|bool"
|
||||
when: "run_setup|bool and matrix_bot_maubot_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-mx-puppet-skype
|
||||
- setup-bot-maubot
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_mx_puppet_skype_enabled|bool"
|
||||
when: "run_setup|bool and not matrix_bot_maubot_enabled|bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-mx-puppet-skype
|
||||
- setup-bot-maubot
|
73
roles/matrix-bot-maubot/tasks/setup_install.yml
Normal file
73
roles/matrix-bot-maubot/tasks/setup_install.yml
Normal file
@ -0,0 +1,73 @@
|
||||
---
|
||||
|
||||
- name: Ensure maubot paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_bot_maubot_base_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_config_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_data_path }}/plugins", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_data_path }}/dbs", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_data_path }}/trash", when: true}
|
||||
- {path: "{{ matrix_bot_maubot_docker_src_files_path }}", when: "{{ matrix_bot_maubot_container_image_self_build }}"}
|
||||
when: "item.when|bool"
|
||||
|
||||
- name: Ensure maubot configuration file created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/config/config.yaml.j2"
|
||||
dest: "{{ matrix_bot_maubot_config_path }}/config.yaml"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: "u=rwx"
|
||||
|
||||
- name: Ensure maubot image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_maubot_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_maubot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_maubot_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_maubot_container_image_self_build|bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure maubot repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_maubot_docker_repo }}"
|
||||
version: "{{ matrix_bot_maubot_docker_repo_version }}"
|
||||
dest: "{{ matrix_bot_maubot_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_maubot_git_pull_results
|
||||
when: "matrix_bot_maubot_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure maubot image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_maubot_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_bot_maubot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_maubot_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_maubot_container_image_self_build|bool"
|
||||
|
||||
- name: Ensure matrix-bot-maubot.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-maubot.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-maubot.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_maubot_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-maubot.service installation
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_maubot_systemd_service_result.changed|bool"
|
36
roles/matrix-bot-maubot/tasks/setup_uninstall.yml
Normal file
36
roles/matrix-bot-maubot/tasks/setup_uninstall.yml
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-maubot service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-maubot.service"
|
||||
register: matrix_bot_maubot_service_stat
|
||||
|
||||
- name: Ensure matrix-bot-maubot is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-maubot
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_maubot_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure matrix-bot-maubot.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-maubot.service"
|
||||
state: absent
|
||||
when: "matrix_bot_maubot_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-maubot.service removal
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_maubot_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure Matrix maubot paths don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_maubot_base_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Ensure maubot Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_bot_maubot_docker_image }}"
|
||||
state: absent
|
10
roles/matrix-bot-maubot/tasks/validate_config.yml
Normal file
10
roles/matrix-bot-maubot/tasks/validate_config.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_bot_maubot_unshared_secret
|
||||
- matrix_bot_maubot_admins
|
110
roles/matrix-bot-maubot/templates/config/config.yaml.j2
Normal file
110
roles/matrix-bot-maubot/templates/config/config.yaml.j2
Normal file
@ -0,0 +1,110 @@
|
||||
# The full URI to the database. SQLite and Postgres are fully supported.
|
||||
# Other DBMSes supported by SQLAlchemy may or may not work.
|
||||
# Format examples:
|
||||
# SQLite: sqlite:///filename.db
|
||||
# Postgres: postgresql://username:password@hostname/dbname
|
||||
database: {{ matrix_bot_maubot_database_uri|to_json }}
|
||||
|
||||
# Separate database URL for the crypto database. "default" means use the same database as above.
|
||||
crypto_database:
|
||||
type: default
|
||||
|
||||
# Additional arguments for asyncpg.create_pool() or sqlite3.connect()
|
||||
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
|
||||
# https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
|
||||
# For sqlite, min_size is used as the connection thread pool size and max_size is ignored.
|
||||
database_opts:
|
||||
min_size: 1
|
||||
max_size: 10
|
||||
plugin_directories:
|
||||
# The directory where uploaded new plugins should be stored.
|
||||
upload: /data/plugins
|
||||
# The directories from which plugins should be loaded.
|
||||
# Duplicate plugin IDs will be moved to the trash.
|
||||
load:
|
||||
- /data/plugins
|
||||
trash: /data/trash
|
||||
|
||||
# Configuration for storing plugin databases
|
||||
plugin_databases:
|
||||
# Some plugins still require sqlite, so configure a path here.
|
||||
# postgres will be used if supported.
|
||||
sqlite: /data/dbs
|
||||
postgres: default
|
||||
|
||||
server:
|
||||
# The IP and port to listen to.
|
||||
hostname: 0.0.0.0
|
||||
port: {{ matrix_bot_maubot_management_interface_port|to_json }}
|
||||
# Public base URL where the server is visible.
|
||||
public_url: {{ matrix_bot_maubot_bot_server_public_url|to_json }}
|
||||
# The base management API path.
|
||||
base_path: /_matrix/maubot/v1
|
||||
# The base path for the UI.
|
||||
ui_base_path: /_matrix/maubot
|
||||
# The base path for plugin endpoints. The instance ID will be appended directly.
|
||||
plugin_base_path: /_matrix/maubot/plugin/
|
||||
# Override path from where to load UI resources.
|
||||
# Set to false to using pkg_resources to find the path.
|
||||
override_resource_path: /opt/maubot/frontend
|
||||
# The base appservice API path. Use / for legacy appservice API and /_matrix/app/v1 for v1.
|
||||
appservice_base_path: /_matrix/app/v1
|
||||
# The shared secret to sign API access tokens.
|
||||
# Set to "generate" to generate and save a new token at startup.
|
||||
unshared_secret: {{ matrix_bot_maubot_unshared_secret|to_json }}
|
||||
|
||||
# Known homeservers. This is required for the `mbc auth` command and also allows
|
||||
# more convenient access from the management UI. This is not required to create
|
||||
# clients in the management UI, since you can also just type the homeserver URL
|
||||
# into the box there.
|
||||
homeservers:
|
||||
{{ matrix_domain }}:
|
||||
# Client-server API URL
|
||||
url: "https://{{ matrix_server_fqn_matrix }}"
|
||||
# registration_shared_secret from synapse config
|
||||
# You can leave this empty if you don't have access to the homeserver.
|
||||
# When this is empty, `mbc auth --register` won't work, but `mbc auth` (login) will.
|
||||
secret: {{ matrix_bot_maubot_registration_shared_secret|to_json }}
|
||||
|
||||
# List of administrator users. Plaintext passwords will be bcrypted on startup. Set empty password
|
||||
# to prevent normal login. Root is a special user that can't have a password and will always exist.
|
||||
admins: {{ matrix_bot_maubot_admins | combine( {"root": ""} )|to_json }}
|
||||
|
||||
api_features:
|
||||
login: true
|
||||
plugin: true
|
||||
plugin_upload: true
|
||||
instance: true
|
||||
instance_database: true
|
||||
client: true
|
||||
client_proxy: true
|
||||
client_auth: true
|
||||
dev_open: true
|
||||
log: true
|
||||
|
||||
# Python logging configuration.
|
||||
#
|
||||
# See section 16.7.2 of the Python documentation for more info:
|
||||
# https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema
|
||||
logging:
|
||||
version: 1
|
||||
formatters:
|
||||
colored:
|
||||
(): maubot.lib.color_log.ColorFormatter
|
||||
format: '[%(asctime)s] [%(levelname)s@%(name)s] %(message)s'
|
||||
normal:
|
||||
format: '[%(asctime)s] [%(levelname)s@%(name)s] %(message)s'
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
formatter: colored
|
||||
loggers:
|
||||
maubot:
|
||||
level: {{ matrix_bot_maubot_logging_level|to_json }}
|
||||
mau:
|
||||
level: {{ matrix_bot_maubot_logging_level|to_json }}
|
||||
aiohttp:
|
||||
level: {{ matrix_bot_maubot_logging_level|to_json }}
|
||||
root:
|
||||
level: {{ matrix_bot_maubot_logging_level|to_json }}
|
||||
handlers: [console]
|
@ -0,0 +1,43 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Maubot
|
||||
{% for service in matrix_bot_maubot_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_bot_maubot_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ matrix_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-maubot 2>/dev/null || true'
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-maubot 2>/dev/null || true'
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-maubot \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--read-only \
|
||||
--cap-drop=ALL \
|
||||
--mount type=bind,src={{ matrix_bot_maubot_config_path }},dst=/config,ro \
|
||||
--mount type=bind,src={{ matrix_bot_maubot_data_path }},dst=/data \
|
||||
{% for arg in matrix_bot_maubot_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
--network={{ matrix_docker_network }} \
|
||||
{% if matrix_bot_maubot_management_interface_http_bind_port %}
|
||||
-p {{ matrix_bot_maubot_management_interface_http_bind_port }}:{{ matrix_bot_maubot_management_interface_port }} \
|
||||
{% endif %}
|
||||
{{ matrix_bot_maubot_docker_image }} \
|
||||
python3 -m maubot -c /config/config.yaml --no-update
|
||||
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-maubot 2>/dev/null || true'
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-maubot 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-bot-maubot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
# A moderation tool for Matrix
|
||||
# See: https://github.com/matrix-org/mjolnir
|
||||
# Project source code URL: https://github.com/matrix-org/mjolnir
|
||||
|
||||
matrix_bot_mjolnir_enabled: true
|
||||
|
||||
matrix_bot_mjolnir_version: "v1.4.1"
|
||||
matrix_bot_mjolnir_version: "v1.5.0"
|
||||
|
||||
matrix_bot_mjolnir_container_image_self_build: false
|
||||
matrix_bot_mjolnir_container_image_self_build_repo: "https://github.com/matrix-org/mjolnir.git"
|
||||
@ -52,8 +52,8 @@ matrix_bot_mjolnir_configuration_extension_yaml: |
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_bot_mjolnir_configuration_yaml`.
|
||||
|
||||
matrix_bot_mjolnir_configuration_extension: "{{ matrix_bot_mjolnir_configuration_extension_yaml|from_yaml if matrix_bot_mjolnir_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_bot_mjolnir_configuration_extension: "{{ matrix_bot_mjolnir_configuration_extension_yaml | from_yaml if matrix_bot_mjolnir_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
# Holds the final configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_bot_mjolnir_configuration_yaml`.
|
||||
matrix_bot_mjolnir_configuration: "{{ matrix_bot_mjolnir_configuration_yaml|from_yaml|combine(matrix_bot_mjolnir_configuration_extension, recursive=True) }}"
|
||||
matrix_bot_mjolnir_configuration: "{{ matrix_bot_mjolnir_configuration_yaml | from_yaml | combine(matrix_bot_mjolnir_configuration_extension, recursive=True) }}"
|
||||
|
@ -2,10 +2,10 @@
|
||||
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
|
||||
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
|
||||
- name: Fail if trying to self-build on Ansible < 2.8
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "To self-build the Mjolnir image, you should use Ansible 2.8 or higher. See docs/ansible.md"
|
||||
when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_bot_mjolnir_container_image_self_build and matrix_bot_mjolnir_enabled"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-mjolnir.service'] }}"
|
||||
when: matrix_bot_mjolnir_enabled|bool
|
||||
when: matrix_bot_mjolnir_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_bot_mjolnir_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-mjolnir
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_bot_mjolnir_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-mjolnir
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_bot_mjolnir_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_bot_mjolnir_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-bot-mjolnir
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_bot_mjolnir_requires_restart: false
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -15,7 +15,7 @@
|
||||
- {path: "{{ matrix_bot_mjolnir_config_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_mjolnir_data_path }}", when: true}
|
||||
- {path: "{{ matrix_bot_mjolnir_docker_src_files_path }}", when: "{{ matrix_bot_mjolnir_container_image_self_build }}"}
|
||||
when: "item.when|bool"
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure mjolnir Docker image is pulled
|
||||
docker_image:
|
||||
@ -23,14 +23,14 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_bot_mjolnir_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_mjolnir_docker_image_force_pull }}"
|
||||
when: "not matrix_bot_mjolnir_container_image_self_build|bool"
|
||||
when: "not matrix_bot_mjolnir_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure mjolnir repository is present on self-build
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_bot_mjolnir_container_image_self_build_repo }}"
|
||||
dest: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
|
||||
version: "{{ matrix_bot_mjolnir_docker_image.split(':')[1] }}"
|
||||
@ -38,7 +38,7 @@
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_bot_mjolnir_git_pull_results
|
||||
when: "matrix_bot_mjolnir_container_image_self_build|bool"
|
||||
when: "matrix_bot_mjolnir_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure mjolnir Docker image is built
|
||||
docker_image:
|
||||
@ -49,30 +49,30 @@
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_bot_mjolnir_container_image_self_build|bool"
|
||||
when: "matrix_bot_mjolnir_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir config installed
|
||||
copy:
|
||||
content: "{{ matrix_bot_mjolnir_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_bot_mjolnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_bot_mjolnir_config_path }}/production.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-bot-mjolnir.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
|
||||
mode: 0644
|
||||
register: matrix_bot_mjolnir_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-mjolnir.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_mjolnir_systemd_service_result.changed|bool"
|
||||
when: "matrix_bot_mjolnir_systemd_service_result.changed | bool"
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-bot-mjolnir.service"
|
||||
state: restarted
|
||||
when: "matrix_bot_mjolnir_requires_restart|bool"
|
||||
when: "matrix_bot_mjolnir_requires_restart | bool"
|
||||
|
@ -1,32 +1,32 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-bot-mjolnir service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
|
||||
register: matrix_bot_mjolnir_service_stat
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-bot-mjolnir
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
register: stopping_result
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
|
||||
state: absent
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-bot-mjolnir.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists|bool"
|
||||
when: "matrix_bot_mjolnir_service_stat.stat.exists | bool"
|
||||
|
||||
- name: Ensure matrix-bot-mjolnir paths don't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_bot_mjolnir_base_path }}"
|
||||
state: absent
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Fail if required variables are undefined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "The `{{ item }}` variable must be defined and have a non-null value."
|
||||
with_items:
|
||||
- "matrix_bot_mjolnir_access_token"
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
# matrix-appservice-discord is a Matrix <-> Discord bridge
|
||||
# See: https://github.com/Half-Shot/matrix-appservice-discord
|
||||
# Project source code URL: https://github.com/Half-Shot/matrix-appservice-discord
|
||||
|
||||
matrix_appservice_discord_enabled: true
|
||||
|
||||
@ -39,10 +39,10 @@ matrix_appservice_discord_appservice_url: 'http://matrix-appservice-discord:9005
|
||||
|
||||
matrix_appservice_discord_bridge_domain: "{{ matrix_domain }}"
|
||||
# As of right now, the homeserver URL must be a public URL. See below.
|
||||
matrix_appservice_discord_bridge_homeserverUrl: "{{ matrix_homeserver_url }}"
|
||||
matrix_appservice_discord_bridge_disablePresence: false
|
||||
matrix_appservice_discord_bridge_enableSelfServiceBridging: false
|
||||
matrix_appservice_discord_bridge_disablePortalBridging: false
|
||||
matrix_appservice_discord_bridge_homeserverUrl: "{{ matrix_homeserver_url }}" # noqa var-naming
|
||||
matrix_appservice_discord_bridge_disablePresence: false # noqa var-naming
|
||||
matrix_appservice_discord_bridge_enableSelfServiceBridging: false # noqa var-naming
|
||||
matrix_appservice_discord_bridge_disablePortalBridging: false # noqa var-naming
|
||||
|
||||
# Database-related configuration fields.
|
||||
#
|
||||
@ -65,7 +65,7 @@ matrix_appservice_discord_database_name: 'matrix_appservice_discord'
|
||||
# These 2 variables are what actually ends up in the bridge configuration.
|
||||
# It's best if you don't change them directly, but rather redefine the sub-variables that constitute them.
|
||||
matrix_appservice_discord_database_filename: "{{ matrix_appservice_discord_sqlite_database_path_in_container }}"
|
||||
matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_database_username }}:{{ matrix_appservice_discord_database_password }}@{{ matrix_appservice_discord_database_hostname }}:{{ matrix_appservice_discord_database_port }}/{{ matrix_appservice_discord_database_name }}'
|
||||
matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_database_username }}:{{ matrix_appservice_discord_database_password }}@{{ matrix_appservice_discord_database_hostname }}:{{ matrix_appservice_discord_database_port }}/{{ matrix_appservice_discord_database_name }}' # noqa var-naming
|
||||
|
||||
|
||||
# Tells whether the bot should make use of "Privileged Gateway Intents".
|
||||
@ -74,7 +74,7 @@ matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservic
|
||||
# by triggering all Intent checkboxes on a page like this: `https://discord.com/developers/applications/694448564151123988/bot`
|
||||
#
|
||||
# Learn more: https://gist.github.com/advaith1/e69bcc1cdd6d0087322734451f15aa2f
|
||||
matrix_appservice_discord_auth_usePrivilegedIntents: false
|
||||
matrix_appservice_discord_auth_usePrivilegedIntents: false # noqa var-naming
|
||||
|
||||
matrix_appservice_discord_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"
|
||||
|
||||
@ -87,9 +87,9 @@ matrix_appservice_discord_configuration_extension_yaml: |
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_appservice_discord_configuration_yaml`.
|
||||
|
||||
matrix_appservice_discord_configuration_extension: "{{ matrix_appservice_discord_configuration_extension_yaml|from_yaml if matrix_appservice_discord_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_appservice_discord_configuration_extension: "{{ matrix_appservice_discord_configuration_extension_yaml | from_yaml if matrix_appservice_discord_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
matrix_appservice_discord_configuration: "{{ matrix_appservice_discord_configuration_yaml|from_yaml|combine(matrix_appservice_discord_configuration_extension, recursive=True) }}"
|
||||
matrix_appservice_discord_configuration: "{{ matrix_appservice_discord_configuration_yaml | from_yaml | combine(matrix_appservice_discord_configuration_extension, recursive=True) }}"
|
||||
|
||||
matrix_appservice_discord_registration_yaml: |
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
@ -99,14 +99,14 @@ matrix_appservice_discord_registration_yaml: |
|
||||
namespaces:
|
||||
users:
|
||||
- exclusive: true
|
||||
regex: '@_discord_.*:{{ matrix_appservice_discord_homeserver_domain|regex_escape }}'
|
||||
regex: '@_discord_.*:{{ matrix_appservice_discord_homeserver_domain | regex_escape }}'
|
||||
aliases:
|
||||
- exclusive: true
|
||||
regex: '#_discord_.*:{{ matrix_appservice_discord_homeserver_domain|regex_escape }}'
|
||||
regex: '#_discord_.*:{{ matrix_appservice_discord_homeserver_domain | regex_escape }}'
|
||||
url: {{ matrix_appservice_discord_appservice_url }}
|
||||
sender_localpart: _discord_bot
|
||||
rate_limited: false
|
||||
protocols:
|
||||
- discord
|
||||
|
||||
matrix_appservice_discord_registration: "{{ matrix_appservice_discord_registration_yaml|from_yaml }}"
|
||||
matrix_appservice_discord_registration: "{{ matrix_appservice_discord_registration_yaml | from_yaml }}"
|
||||
|
@ -2,24 +2,28 @@
|
||||
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
|
||||
# We don't want to fail in such cases.
|
||||
- name: Fail if matrix-synapse role already executed
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
The matrix-bridge-appservice-discord role needs to execute before the matrix-synapse role.
|
||||
when: "matrix_appservice_discord_enabled and matrix_synapse_role_executed|default(False)"
|
||||
when: "matrix_appservice_discord_enabled and matrix_synapse_role_executed | default(False)"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-discord.service'] }}"
|
||||
when: matrix_appservice_discord_enabled|bool
|
||||
when: matrix_appservice_discord_enabled | bool
|
||||
|
||||
# If the matrix-synapse role is not used, these variables may not exist.
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_synapse_container_extra_arguments: >
|
||||
{{ matrix_synapse_container_extra_arguments|default([]) }}
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_appservice_discord_config_path }}/registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro"]
|
||||
{{
|
||||
matrix_synapse_container_extra_arguments | default([])
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_appservice_discord_config_path }}/registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro"]
|
||||
}}
|
||||
|
||||
matrix_synapse_app_service_config_files: >
|
||||
{{ matrix_synapse_app_service_config_files|default([]) }}
|
||||
+
|
||||
{{ ["/matrix-appservice-discord-registration.yaml"] }}
|
||||
when: matrix_appservice_discord_enabled|bool
|
||||
{{
|
||||
matrix_synapse_app_service_config_files | default([])
|
||||
+
|
||||
["/matrix-appservice-discord-registration.yaml"]
|
||||
}}
|
||||
when: matrix_appservice_discord_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_appservice_discord_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_appservice_discord_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-discord
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_appservice_discord_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_appservice_discord_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-discord
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_appservice_discord_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_appservice_discord_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-discord
|
||||
|
@ -1,29 +1,31 @@
|
||||
---
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_discord_requires_restart: false
|
||||
|
||||
- block:
|
||||
- name: Check if an SQLite database already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||
register: matrix_appservice_discord_sqlite_database_path_local_stat_result
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_postgres_db_migration_request:
|
||||
src: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_appservice_discord_database_connString }}"
|
||||
caller: "{{ role_path|basename }}"
|
||||
caller: "{{ role_path | basename }}"
|
||||
engine_variable_name: 'matrix_appservice_discord_database_engine'
|
||||
engine_old: 'sqlite'
|
||||
systemd_services_to_stop: ['matrix-appservice-discord.service']
|
||||
|
||||
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: migrate_db_to_postgres
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_discord_requires_restart: true
|
||||
when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists|bool"
|
||||
when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
when: "matrix_appservice_discord_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure Appservice Discord image is pulled
|
||||
@ -38,7 +40,7 @@
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure AppService Discord paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -50,12 +52,12 @@
|
||||
- "{{ matrix_appservice_discord_data_path }}"
|
||||
|
||||
- name: Check if an old database file already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_discord_base_path }}/discord.db"
|
||||
register: matrix_appservice_discord_stat_db
|
||||
|
||||
- name: (Data relocation) Ensure matrix-appservice-discord.service is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-discord
|
||||
state: stopped
|
||||
enabled: false
|
||||
@ -64,7 +66,7 @@
|
||||
when: "matrix_appservice_discord_stat_db.stat.exists"
|
||||
|
||||
- name: (Data relocation) Move AppService Discord discord.db file to ./data directory
|
||||
command: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}"
|
||||
ansible.builtin.command: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}"
|
||||
with_items:
|
||||
- discord.db
|
||||
- user-store.db
|
||||
@ -72,16 +74,16 @@
|
||||
when: "matrix_appservice_discord_stat_db.stat.exists"
|
||||
|
||||
- name: Ensure AppService Discord config.yaml installed
|
||||
copy:
|
||||
content: "{{ matrix_appservice_discord_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_discord_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_discord_config_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure AppService Discord registration.yaml installed
|
||||
copy:
|
||||
content: "{{ matrix_appservice_discord_registration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_discord_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
@ -90,7 +92,7 @@
|
||||
# If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated.
|
||||
# We intentionally suppress Ansible changes.
|
||||
- name: Generate AppService Discord invite link
|
||||
shell: >-
|
||||
ansible.builtin.shell: >-
|
||||
{{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
|
||||
--cap-drop=ALL
|
||||
@ -101,19 +103,19 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure matrix-appservice-discord.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
|
||||
mode: 0644
|
||||
register: matrix_appservice_discord_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-discord.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_discord_systemd_service_result.changed"
|
||||
|
||||
- name: Ensure matrix-appservice-discord.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-appservice-discord.service"
|
||||
state: restarted
|
||||
when: "matrix_appservice_discord_requires_restart|bool"
|
||||
when: "matrix_appservice_discord_requires_restart | bool"
|
||||
|
@ -1,12 +1,12 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-appservice-discord service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
|
||||
register: matrix_appservice_discord_service_stat
|
||||
|
||||
- name: Ensure matrix-appservice-discord is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-discord
|
||||
state: stopped
|
||||
enabled: false
|
||||
@ -14,12 +14,12 @@
|
||||
when: "matrix_appservice_discord_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-appservice-discord.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
|
||||
state: absent
|
||||
when: "matrix_appservice_discord_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-discord.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_discord_service_stat.stat.exists"
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
@ -13,7 +13,7 @@
|
||||
- "matrix_appservice_discord_homeserver_domain"
|
||||
|
||||
- name: (Deprecation) Catch and report renamed appservice-discord variables
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
|
||||
@ -22,5 +22,5 @@
|
||||
- {'old': 'matrix_appservice_discord_container_expose_client_server_api_port', 'new': '<superseded by matrix_appservice_discord_container_http_host_bind_port>'}
|
||||
|
||||
- name: Require a valid database engine
|
||||
fail: msg="`matrix_appservice_discord_database_engine` needs to be either 'sqlite' or 'postgres'"
|
||||
ansible.builtin.fail: msg="`matrix_appservice_discord_database_engine` needs to be either 'sqlite' or 'postgres'"
|
||||
when: "matrix_appservice_discord_database_engine not in ['sqlite', 'postgres']"
|
||||
|
@ -34,7 +34,7 @@ bridge:
|
||||
determineCodeLanguage: false
|
||||
# Authentication configuration for the discord bot.
|
||||
auth:
|
||||
clientID: {{ matrix_appservice_discord_client_id|string|to_json }}
|
||||
clientID: {{ matrix_appservice_discord_client_id | string|to_json }}
|
||||
botToken: {{ matrix_appservice_discord_bot_token|to_json }}
|
||||
# You must enable "Privileged Gateway Intents" in your bot settings on discord.com (e.g. https://discord.com/developers/applications/12345/bot)
|
||||
# for this to work
|
||||
|
@ -1,15 +1,19 @@
|
||||
---
|
||||
# Matrix Appservice IRC is a Matrix <-> IRC bridge
|
||||
# See: https://github.com/matrix-org/matrix-appservice-irc
|
||||
# Project source code URL: https://github.com/matrix-org/matrix-appservice-irc
|
||||
|
||||
matrix_appservice_irc_enabled: true
|
||||
|
||||
matrix_appservice_irc_container_image_self_build: false
|
||||
matrix_appservice_irc_docker_repo: "https://github.com/matrix-org/matrix-appservice-irc.git"
|
||||
matrix_appservice_irc_docker_repo_version: "{{ 'master' if matrix_appservice_irc_version == 'latest' else matrix_appservice_irc_version }}"
|
||||
matrix_appservice_irc_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-irc/docker-src"
|
||||
|
||||
matrix_appservice_irc_version: release-0.33.0
|
||||
matrix_appservice_irc_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-irc:{{ matrix_appservice_irc_version }}"
|
||||
# matrix_appservice_irc_version used to contain the full Docker image tag (e.g. `release-X.X.X`).
|
||||
# It's a bare version number now. We try to somewhat retain compatibility below.
|
||||
matrix_appservice_irc_version: 0.34.0
|
||||
matrix_appservice_irc_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-irc:{{ matrix_appservice_irc_docker_image_tag }}"
|
||||
matrix_appservice_irc_docker_image_tag: "{{ 'latest' if matrix_appservice_irc_version == 'latest' else ('release-' + matrix_appservice_irc_version) }}"
|
||||
matrix_appservice_irc_docker_image_force_pull: "{{ matrix_appservice_irc_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_appservice_irc_base_path: "{{ matrix_base_data_path }}/appservice-irc"
|
||||
@ -19,7 +23,7 @@ matrix_appservice_irc_data_path: "{{ matrix_appservice_irc_base_path }}/data"
|
||||
matrix_appservice_irc_homeserver_url: "{{ matrix_homeserver_container_url }}"
|
||||
matrix_appservice_irc_homeserver_media_url: 'https://{{ matrix_server_fqn_matrix }}'
|
||||
matrix_appservice_irc_homeserver_domain: '{{ matrix_domain }}'
|
||||
matrix_appservice_irc_homeserver_enablePresence: true
|
||||
matrix_appservice_irc_homeserver_enablePresence: true # noqa var-naming
|
||||
matrix_appservice_irc_appservice_address: 'http://matrix-appservice-irc:9999'
|
||||
|
||||
matrix_appservice_irc_database_engine: nedb
|
||||
@ -34,14 +38,15 @@ matrix_appservice_irc_database_name: matrix_appservice_irc
|
||||
matrix_appservice_irc_database_connection_string: 'postgresql://{{ matrix_appservice_irc_database_username }}:{{ matrix_appservice_irc_database_password }}@{{ matrix_appservice_irc_database_hostname }}:{{ matrix_appservice_irc_database_port }}/{{ matrix_appservice_irc_database_name }}?sslmode=disable'
|
||||
|
||||
# This is what actually goes into `database.connectionString` for the bridge.
|
||||
matrix_appservice_irc_database_connectionString: "{{
|
||||
{
|
||||
'nedb': 'nedb:///data',
|
||||
'postgres': matrix_appservice_irc_database_connection_string,
|
||||
}[matrix_appservice_irc_database_engine]
|
||||
}}"
|
||||
matrix_appservice_irc_database_connectionString: |- # noqa var-naming
|
||||
{{
|
||||
{
|
||||
'nedb': 'nedb:///data',
|
||||
'postgres': matrix_appservice_irc_database_connection_string,
|
||||
}[matrix_appservice_irc_database_engine]
|
||||
}}
|
||||
|
||||
matrix_appservice_irc_ircService_servers: []
|
||||
matrix_appservice_irc_ircService_servers: [] # noqa var-naming
|
||||
|
||||
# Example of `matrix_appservice_irc_ircService_servers` with one server (and all its options):
|
||||
#
|
||||
@ -382,9 +387,9 @@ matrix_appservice_irc_configuration_extension_yaml: |
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_appservice_irc_configuration_yaml`.
|
||||
|
||||
matrix_appservice_irc_configuration_extension: "{{ matrix_appservice_irc_configuration_extension_yaml|from_yaml if matrix_appservice_irc_configuration_extension_yaml|from_yaml is mapping else {} }}"
|
||||
matrix_appservice_irc_configuration_extension: "{{ matrix_appservice_irc_configuration_extension_yaml | from_yaml if matrix_appservice_irc_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
matrix_appservice_irc_configuration: "{{ matrix_appservice_irc_configuration_yaml|from_yaml|combine(matrix_appservice_irc_configuration_extension, recursive=True) }}"
|
||||
matrix_appservice_irc_configuration: "{{ matrix_appservice_irc_configuration_yaml | from_yaml | combine(matrix_appservice_irc_configuration_extension, recursive=True) }}"
|
||||
|
||||
# The original registration.yaml file generated by AppService IRC is merged with this config override,
|
||||
# to produce the final registration.yaml file ultimately used by both the bridge and the homeserver.
|
||||
@ -399,4 +404,4 @@ matrix_appservice_irc_registration_override_yaml: |
|
||||
as_token: "{{ matrix_appservice_irc_appservice_token }}"
|
||||
hs_token: "{{ matrix_appservice_irc_homeserver_token }}"
|
||||
|
||||
matrix_appservice_irc_registration_override: "{{ matrix_appservice_irc_registration_override_yaml|from_yaml }}"
|
||||
matrix_appservice_irc_registration_override: "{{ matrix_appservice_irc_registration_override_yaml | from_yaml }}"
|
||||
|
@ -2,31 +2,35 @@
|
||||
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
|
||||
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
|
||||
- name: Fail if trying to self-build on Ansible < 2.8
|
||||
fail:
|
||||
msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md"
|
||||
ansible.builtin.fail:
|
||||
msg: "To self-build the matrix-appservice-irc image, you should use Ansible 2.8 or higher. See docs/ansible.md"
|
||||
when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_irc_container_image_self_build and matrix_appservice_irc_enabled"
|
||||
|
||||
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
|
||||
# We don't want to fail in such cases.
|
||||
- name: Fail if matrix-synapse role already executed
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
The matrix-bridge-appservice-irc role needs to execute before the matrix-synapse role.
|
||||
when: "matrix_appservice_irc_enabled|bool and matrix_synapse_role_executed|default(False)"
|
||||
when: "matrix_appservice_irc_enabled | bool and matrix_synapse_role_executed | default(False)"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-irc.service'] }}"
|
||||
when: matrix_appservice_irc_enabled|bool
|
||||
when: matrix_appservice_irc_enabled | bool
|
||||
|
||||
# If the matrix-synapse role is not used, these variables may not exist.
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_synapse_container_extra_arguments: >
|
||||
{{ matrix_synapse_container_extra_arguments|default([]) }}
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_appservice_irc_config_path }}/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro"]
|
||||
{{
|
||||
matrix_synapse_container_extra_arguments | default([])
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_appservice_irc_config_path }}/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro"]
|
||||
}}
|
||||
|
||||
matrix_synapse_app_service_config_files: >
|
||||
{{ matrix_synapse_app_service_config_files|default([]) }}
|
||||
+
|
||||
{{ ["/matrix-appservice-irc-registration.yaml"] }}
|
||||
when: matrix_appservice_irc_enabled|bool
|
||||
{{
|
||||
matrix_synapse_app_service_config_files | default([])
|
||||
+
|
||||
["/matrix-appservice-irc-registration.yaml"]
|
||||
}}
|
||||
when: matrix_appservice_irc_enabled | bool
|
||||
|
@ -1,23 +1,23 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup|bool and matrix_appservice_irc_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_appservice_irc_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-irc
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup|bool and matrix_appservice_irc_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_appservice_irc_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-irc
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup|bool and not matrix_appservice_irc_enabled|bool"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_appservice_irc_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-irc
|
||||
|
@ -1,46 +1,46 @@
|
||||
---
|
||||
|
||||
- name: Fail if Postgres not enabled
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Postgres via the matrix-postgres role is not enabled (`matrix_postgres_enabled`). Cannot migrate."
|
||||
when: "not matrix_postgres_enabled|bool"
|
||||
when: "not matrix_postgres_enabled | bool"
|
||||
|
||||
# Defaults
|
||||
|
||||
- name: Set postgres_start_wait_time, if not provided
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
postgres_start_wait_time: 15
|
||||
when: "postgres_start_wait_time|default('') == ''"
|
||||
when: "postgres_start_wait_time | default('') == ''"
|
||||
|
||||
# Actual import work
|
||||
|
||||
- name: Ensure matrix-postgres is started
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-postgres
|
||||
state: started
|
||||
daemon_reload: true
|
||||
register: matrix_postgres_service_start_result
|
||||
|
||||
- name: Wait a bit, so that Postgres can start
|
||||
wait_for:
|
||||
ansible.builtin.wait_for:
|
||||
timeout: "{{ postgres_start_wait_time }}"
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
when: "matrix_postgres_service_start_result.changed|bool"
|
||||
when: "matrix_postgres_service_start_result.changed | bool"
|
||||
|
||||
- name: Check existence of matrix-appservice-irc service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
|
||||
register: matrix_appservice_irc_service_stat
|
||||
|
||||
- name: Ensure matrix-appservice-irc is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-irc
|
||||
state: stopped
|
||||
when: "matrix_appservice_irc_service_stat.stat.exists"
|
||||
|
||||
- name: Import appservice-irc NeDB database into Postgres
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: >-
|
||||
{{ matrix_host_command_docker }} run
|
||||
--rm
|
||||
@ -52,19 +52,23 @@
|
||||
{{ matrix_appservice_irc_docker_image }}
|
||||
-c
|
||||
'/usr/local/bin/node /app/lib/scripts/migrate-db-to-pgres.js --dbdir /data --privateKey /data/passkey.pem --connectionString {{ matrix_appservice_irc_database_connection_string }}'
|
||||
register: matrix_appservice_irc_import_nedb_to_postgres_result
|
||||
changed_when: matrix_appservice_irc_import_nedb_to_postgres_result.rc == 0
|
||||
|
||||
- name: Archive NeDB database files
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup"
|
||||
with_items:
|
||||
- rooms.db
|
||||
- users.db
|
||||
register: matrix_appservice_irc_import_nedb_to_postgres_move_result
|
||||
changed_when: matrix_appservice_irc_import_nedb_to_postgres_move_result.rc == 0
|
||||
|
||||
- name: Inject result
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
matrix_playbook_runtime_results: |
|
||||
{{
|
||||
matrix_playbook_runtime_results|default([])
|
||||
matrix_playbook_runtime_results | default([])
|
||||
+
|
||||
[
|
||||
"NOTE: Your appservice-irc database files have been imported into Postgres. The original database files have been moved from `{{ matrix_appservice_irc_data_path }}/*.db` to `{{ matrix_appservice_irc_data_path }}/*.db.backup`. When you've confirmed that the import went well and everything works, you should be able to safely delete these files."
|
||||
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
|
||||
- import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml"
|
||||
|
||||
- name: Ensure Appservice IRC paths exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
@ -14,47 +14,53 @@
|
||||
- {path: "{{ matrix_appservice_irc_config_path }}", when: true}
|
||||
- {path: "{{ matrix_appservice_irc_data_path }}", when: true}
|
||||
- {path: "{{ matrix_appservice_irc_docker_src_files_path }}", when: "{{ matrix_appservice_irc_container_image_self_build }}"}
|
||||
when: item.when|bool
|
||||
when: item.when | bool
|
||||
|
||||
- name: Check if an old passkey file already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_irc_base_path }}/passkey.pem"
|
||||
register: matrix_appservice_irc_stat_passkey
|
||||
|
||||
- block:
|
||||
- name: (Data relocation) Ensure matrix-appservice-irc.service is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-irc
|
||||
state: stopped
|
||||
daemon_reload: true
|
||||
failed_when: false
|
||||
|
||||
- name: (Data relocation) Move AppService IRC passkey.pem file to ./data directory
|
||||
command: "mv {{ matrix_appservice_irc_base_path }}/passkey.pem {{ matrix_appservice_irc_data_path }}/passkey.pem"
|
||||
ansible.builtin.command:
|
||||
cmd: "mv {{ matrix_appservice_irc_base_path }}/passkey.pem {{ matrix_appservice_irc_data_path }}/passkey.pem"
|
||||
register: matrix_appservice_irc_move_passkey_result
|
||||
changed_when: matrix_appservice_irc_move_passkey_result.rc == 0
|
||||
|
||||
- name: (Data relocation) Move AppService IRC database files to ./data directory
|
||||
command: "mv {{ matrix_appservice_irc_base_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}"
|
||||
ansible.builtin.command:
|
||||
cmd: "mv {{ matrix_appservice_irc_base_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}"
|
||||
register: matrix_appservice_irc_move_dbs_result
|
||||
changed_when: matrix_appservice_irc_move_dbs_result.rc == 0
|
||||
with_items:
|
||||
- rooms.db
|
||||
- users.db
|
||||
failed_when: false
|
||||
when: "matrix_appservice_irc_stat_passkey.stat.exists"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_irc_requires_restart: false
|
||||
|
||||
- block:
|
||||
- name: Check if a nedb database already exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_irc_data_path }}/users.db"
|
||||
register: matrix_appservice_irc_nedb_database_path_local_stat_result
|
||||
|
||||
- block:
|
||||
- import_tasks: "{{ role_path }}/tasks/migrate_nedb_to_postgres.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/migrate_nedb_to_postgres.yml"
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_irc_requires_restart: true
|
||||
when: "matrix_appservice_irc_nedb_database_path_local_stat_result.stat.exists|bool"
|
||||
when: "matrix_appservice_irc_nedb_database_path_local_stat_result.stat.exists | bool"
|
||||
when: "matrix_appservice_irc_database_engine == 'postgres'"
|
||||
|
||||
- name: Ensure Appservice IRC image is pulled
|
||||
@ -63,21 +69,22 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_appservice_irc_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_irc_docker_image_force_pull }}"
|
||||
when: "matrix_appservice_irc_enabled|bool and not matrix_appservice_irc_container_image_self_build|bool"
|
||||
when: "matrix_appservice_irc_enabled | bool and not matrix_appservice_irc_container_image_self_build | bool"
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-appservice-irc repository is present when self-building
|
||||
git:
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_appservice_irc_docker_repo }}"
|
||||
version: "{{ matrix_appservice_irc_docker_repo_version }}"
|
||||
dest: "{{ matrix_appservice_irc_docker_src_files_path }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_appservice_irc_git_pull_results
|
||||
when: "matrix_appservice_irc_enabled|bool and matrix_appservice_irc_container_image_self_build|bool"
|
||||
when: "matrix_appservice_irc_enabled | bool and matrix_appservice_irc_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-appservice-irc Docker image is built
|
||||
docker_image:
|
||||
@ -89,23 +96,23 @@
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_appservice_irc_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_appservice_irc_enabled|bool and matrix_appservice_irc_container_image_self_build|bool and matrix_appservice_irc_git_pull_results.changed"
|
||||
when: "matrix_appservice_irc_enabled | bool and matrix_appservice_irc_container_image_self_build | bool and matrix_appservice_irc_git_pull_results.changed"
|
||||
|
||||
- name: Ensure Matrix Appservice IRC config installed
|
||||
copy:
|
||||
content: "{{ matrix_appservice_irc_configuration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_irc_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_irc_config_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Check if Appservice IRC passkey exists
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_irc_data_path }}/passkey.pem"
|
||||
register: irc_passkey_file
|
||||
|
||||
- name: Generate Appservice IRC passkey if it doesn't exist
|
||||
shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_appservice_irc_data_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048"
|
||||
ansible.builtin.shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_appservice_irc_data_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
when: "not irc_passkey_file.stat.exists"
|
||||
@ -113,7 +120,7 @@
|
||||
# In the past, we used to generate the passkey.pem file with root, so permissions may not be okay.
|
||||
# Fix it.
|
||||
- name: (Migration) Ensure Appservice IRC passkey permissions are okay
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_appservice_irc_data_path }}/passkey.pem"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
@ -139,7 +146,7 @@
|
||||
# an up-to-date file, and we fix it up with some static values later on,
|
||||
# to produce a final registration.yaml file, as we desire.
|
||||
- name: Generate Appservice IRC registration-template.yaml
|
||||
shell: >-
|
||||
ansible.builtin.shell: >-
|
||||
{{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc-gen
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
|
||||
--cap-drop=ALL
|
||||
@ -157,46 +164,46 @@
|
||||
changed_when: false
|
||||
|
||||
- name: Read Appservice IRC registration-template.yaml
|
||||
slurp:
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml"
|
||||
register: matrix_appservice_irc_registration_template_slurp
|
||||
|
||||
- name: Remove unnecessary Appservice IRC registration-template.yaml
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml"
|
||||
state: absent
|
||||
changed_when: false
|
||||
|
||||
- name: Parse registration-template.yaml
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
matrix_appservice_irc_registration_template: "{{ matrix_appservice_irc_registration_template_slurp['content'] | b64decode | from_yaml }}"
|
||||
|
||||
- name: Combine registration-template.yaml and own registration override config
|
||||
set_fact:
|
||||
matrix_appservice_irc_registration: "{{ matrix_appservice_irc_registration_template|combine(matrix_appservice_irc_registration_override, recursive=True) }}"
|
||||
ansible.builtin.set_fact:
|
||||
matrix_appservice_irc_registration: "{{ matrix_appservice_irc_registration_template | combine(matrix_appservice_irc_registration_override, recursive=True) }}"
|
||||
|
||||
- name: Ensure Appservice IRC registration.yaml installed
|
||||
copy:
|
||||
content: "{{ matrix_appservice_irc_registration|to_nice_yaml(indent=2, width=999999) }}"
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_irc_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_irc_config_path }}/registration.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-appservice-irc.service installed
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-appservice-irc.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
|
||||
mode: 0644
|
||||
register: matrix_appservice_irc_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-irc.service installation
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_irc_systemd_service_result.changed"
|
||||
|
||||
- name: Ensure matrix-appservice-irc.service restarted, if necessary
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "matrix-appservice-irc.service"
|
||||
state: restarted
|
||||
when: "matrix_appservice_irc_requires_restart|bool"
|
||||
when: "matrix_appservice_irc_requires_restart | bool"
|
||||
|
@ -1,12 +1,12 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-appservice-irc service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
|
||||
register: matrix_appservice_irc_service_stat
|
||||
|
||||
- name: Ensure matrix-appservice-irc is stopped
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-irc
|
||||
state: stopped
|
||||
enabled: false
|
||||
@ -14,12 +14,12 @@
|
||||
when: "matrix_appservice_irc_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-appservice-irc.service doesn't exist
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
|
||||
state: absent
|
||||
when: "matrix_appservice_irc_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-irc.service removal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_irc_service_stat.stat.exists"
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
@ -17,7 +17,7 @@
|
||||
#
|
||||
# This is a safety check to ensure we fail earlier and in a nicer way.
|
||||
- name: Fail if no additional configuration provided
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your Appservice IRC configuration is incomplete (lacking an `ircService.servers` configuration).
|
||||
You need to define one or more servers by either using `matrix_appservice_irc_ircService_servers`
|
||||
@ -26,7 +26,7 @@
|
||||
when: "matrix_appservice_irc_configuration.ircService.servers|length == 0"
|
||||
|
||||
- name: (Deprecation) Catch and report renamed appservice-irc variables
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Your configuration contains a variable, which now has a different name.
|
||||
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
|
||||
|
200
roles/matrix-bridge-appservice-kakaotalk/defaults/main.yml
Normal file
200
roles/matrix-bridge-appservice-kakaotalk/defaults/main.yml
Normal file
@ -0,0 +1,200 @@
|
||||
---
|
||||
# matrix-appservice-kakaotalk is a Matrix <-> Kakaotalk bridge
|
||||
# Project source code URL: https://src.miscworks.net/fair/matrix-appservice-kakaotalk/
|
||||
|
||||
matrix_appservice_kakaotalk_enabled: true
|
||||
|
||||
# No images are published for neither of the container images (appservice or node), so we're self-building everything.
|
||||
matrix_appservice_kakaotalk_container_image_self_build: true
|
||||
# matrix_appservice_kakaotalk_container_image_self_build_repo: "https://src.miscworks.net/fair/matrix-appservice-kakaotalk.git"
|
||||
#
|
||||
# hnarjis' fork is used instead of upstream (fair's), because upstream is currently broken.
|
||||
# The following error happens when chatting up the bot without this fix:
|
||||
# [2022-07-25 09:04:53,784] [ERROR@mau.as] Exception in Matrix event handler
|
||||
# Traceback (most recent call last):
|
||||
# File "/usr/lib/python3.9/site-packages/mautrix/appservice/as_handler.py", line 239, in try_handle
|
||||
# await handler_func(event)
|
||||
# File "/usr/lib/python3.9/site-packages/mautrix/bridge/matrix.py", line 820, in int_handle_event
|
||||
# await self.int_handle_invite(evt)
|
||||
# File "/usr/lib/python3.9/site-packages/mautrix/bridge/matrix.py", line 441, in int_handle_invite
|
||||
# inviter = await self.bridge.get_user(evt.sender)
|
||||
# File "/usr/lib/python3.9/site-packages/matrix_appservice_kakaotalk/__main__.py", line 112, in get_user
|
||||
# return await User.get_by_mxid(user_id, create=create)
|
||||
# File "/usr/lib/python3.9/site-packages/mautrix/util/async_getter_lock.py", line 60, in wrapper
|
||||
# return await fn(cls, *args, **kwargs)
|
||||
# File "/usr/lib/python3.9/site-packages/matrix_appservice_kakaotalk/user.py", line 227, in get_by_mxid
|
||||
# user = cls(mxid)
|
||||
# TypeError: __init__() missing 2 required positional arguments: 'force_login' and 'was_connected'
|
||||
matrix_appservice_kakaotalk_container_image_self_build_repo: "https://src.miscworks.net/hnarjis/matrix-appservice-kakaotalk.git"
|
||||
matrix_appservice_kakaotalk_container_image_self_build_repo_version: "{{ 'master' if matrix_appservice_kakaotalk_version == 'latest' else matrix_appservice_kakaotalk_version }}"
|
||||
|
||||
matrix_appservice_kakaotalk_node_version: "{{ matrix_appservice_kakaotalk_version }}"
|
||||
matrix_appservice_kakaotalk_node_docker_image: "{{ matrix_appservice_kakaotalk_node_docker_image_prefix }}fair/matrix-appservice-kakaotalk-node:{{ matrix_appservice_kakaotalk_node_version }}"
|
||||
matrix_appservice_kakaotalk_node_docker_image_prefix: "localhost/"
|
||||
matrix_appservice_kakaotalk_node_docker_image_force_pull: "{{ matrix_appservice_kakaotalk_node_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_appservice_kakaotalk_version: 86c038fd2ffee5e0aebf65136f085cce7e38b54e
|
||||
matrix_appservice_kakaotalk_docker_image: "{{ matrix_appservice_kakaotalk_docker_image_name_prefix }}fair/matrix-appservice-kakaotalk:{{ matrix_appservice_kakaotalk_version }}"
|
||||
matrix_appservice_kakaotalk_docker_image_name_prefix: "localhost/"
|
||||
matrix_appservice_kakaotalk_docker_image_force_pull: "{{ matrix_appservice_kakaotalk_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_appservice_kakaotalk_base_path: "{{ matrix_base_data_path }}/appservice-kakaotalk"
|
||||
matrix_appservice_kakaotalk_config_path: "{{ matrix_appservice_kakaotalk_base_path }}/config"
|
||||
matrix_appservice_kakaotalk_data_path: "{{ matrix_appservice_kakaotalk_base_path }}/data"
|
||||
matrix_appservice_kakaotalk_docker_src_files_path: "{{ matrix_appservice_kakaotalk_base_path }}/docker-src"
|
||||
|
||||
matrix_appservice_kakaotalk_command_prefix: "!kt"
|
||||
|
||||
matrix_appservice_kakaotalk_homeserver_address: "{{ matrix_homeserver_container_url }}"
|
||||
matrix_appservice_kakaotalk_homeserver_domain: '{{ matrix_domain }}'
|
||||
matrix_appservice_kakaotalk_appservice_address: 'http://matrix-appservice-kakaotalk:11115'
|
||||
|
||||
|
||||
# A list of extra arguments to pass to the appservice-kakaotalk container
|
||||
matrix_appservice_kakaotalk_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-appservice-kakaotalk.service depends on.
|
||||
matrix_appservice_kakaotalk_systemd_required_services_list: ['docker.service', 'matrix-appservice-kakaotalk-node.service']
|
||||
|
||||
# List of systemd services that matrix-appservice-kakaotalk.service wants
|
||||
matrix_appservice_kakaotalk_systemd_wanted_services_list: []
|
||||
|
||||
|
||||
# A list of extra arguments to pass to the appservice-kakaotalk-node container
|
||||
matrix_appservice_kakaotalk_node_container_extra_arguments: []
|
||||
|
||||
# List of systemd services that matrix-appservice-kakaotalk-node.service depends on.
|
||||
matrix_appservice_kakaotalk_node_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# List of systemd services that matrix-appservice-kakaotalk-node.service wants
|
||||
matrix_appservice_kakaotalk_node_systemd_wanted_services_list: []
|
||||
|
||||
|
||||
matrix_appservice_kakaotalk_appservice_token: ''
|
||||
matrix_appservice_kakaotalk_homeserver_token: ''
|
||||
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
matrix_appservice_kakaotalk_federate_rooms: true
|
||||
|
||||
# Database-related configuration fields.
|
||||
#
|
||||
# To use SQLite:
|
||||
# - change the engine (`matrix_appservice_kakaotalk_database_engine: 'sqlite'`)
|
||||
# To use Postgres:
|
||||
# - adjust your database credentials via the `matrix_appservice_kakaotalk_database_*` variables
|
||||
matrix_appservice_kakaotalk_database_engine: 'postgres'
|
||||
|
||||
matrix_appservice_kakaotalk_sqlite_database_path_local: "{{ matrix_appservice_kakaotalk_data_path }}/appservice-kakaotalk.db"
|
||||
matrix_appservice_kakaotalk_sqlite_database_path_in_container: "/data/appservice-kakaotalk.db"
|
||||
|
||||
matrix_appservice_kakaotalk_database_username: 'matrix_appservice_kakaotalk'
|
||||
matrix_appservice_kakaotalk_database_password: 'some-password'
|
||||
matrix_appservice_kakaotalk_database_hostname: 'matrix-postgres'
|
||||
matrix_appservice_kakaotalk_database_port: 5432
|
||||
matrix_appservice_kakaotalk_database_name: 'matrix_appservice_kakaotalk'
|
||||
|
||||
matrix_appservice_kakaotalk_database_connection_string: 'postgres://{{ matrix_appservice_kakaotalk_database_username }}:{{ matrix_appservice_kakaotalk_database_password }}@{{ matrix_appservice_kakaotalk_database_hostname }}:{{ matrix_appservice_kakaotalk_database_port }}/{{ matrix_appservice_kakaotalk_database_name }}'
|
||||
|
||||
matrix_appservice_kakaotalk_appservice_database: "{{
|
||||
{
|
||||
'sqlite': ('sqlite:///' + matrix_appservice_kakaotalk_sqlite_database_path_in_container),
|
||||
'postgres': matrix_appservice_kakaotalk_database_connection_string,
|
||||
}[matrix_appservice_kakaotalk_database_engine]
|
||||
}}"
|
||||
|
||||
|
||||
# Can be set to enable automatic double-puppeting via Shared Secret Auth (https://github.com/devture/matrix-synapse-shared-secret-auth).
|
||||
# Also see: matrix_appservice_kakaotalk_bridge_login_shared_secret_map
|
||||
matrix_appservice_kakaotalk_login_shared_secret: ''
|
||||
|
||||
matrix_appservice_kakaotalk_bridge_login_shared_secret_map: "{{ {matrix_appservice_kakaotalk_homeserver_domain: matrix_appservice_kakaotalk_login_shared_secret} if matrix_appservice_kakaotalk_login_shared_secret else {} }}"
|
||||
|
||||
matrix_appservice_kakaotalk_bridge_permissions: |
|
||||
{{
|
||||
{matrix_appservice_kakaotalk_homeserver_domain: 'user'}
|
||||
| combine({matrix_admin: 'admin'} if matrix_admin else {})
|
||||
}}
|
||||
|
||||
matrix_appservice_kakaotalk_appservice_bot_username: kakaotalkbot
|
||||
matrix_appservice_kakaotalk_user_prefix: 'kakaotalk_'
|
||||
|
||||
# End-to-bridge encryption configuration
|
||||
matrix_appservice_kakaotalk_bridge_encryption_allow: false
|
||||
matrix_appservice_kakaotalk_bridge_encryption_default: "{{ matrix_appservice_kakaotalk_bridge_encryption_allow }}"
|
||||
|
||||
# Specifies the default log level for all bridge loggers.
|
||||
matrix_appservice_kakaotalk_logging_level: WARNING
|
||||
|
||||
|
||||
# Default configuration template which covers the generic use case.
|
||||
# You can customize it by controlling the various variables inside it.
|
||||
#
|
||||
# For a more advanced customization, you can extend the default (see `matrix_appservice_kakaotalk_configuration_extension_yaml`)
|
||||
# or completely replace this variable with your own template.
|
||||
matrix_appservice_kakaotalk_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"
|
||||
|
||||
matrix_appservice_kakaotalk_configuration_extension_yaml: |
|
||||
# Your custom YAML configuration goes here.
|
||||
# This configuration extends the default starting configuration (`matrix_appservice_kakaotalk_configuration_yaml`).
|
||||
#
|
||||
# You can override individual variables from the default configuration, or introduce new ones.
|
||||
#
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_appservice_kakaotalk_configuration_yaml`.
|
||||
|
||||
matrix_appservice_kakaotalk_configuration_extension: "{{ matrix_appservice_kakaotalk_configuration_extension_yaml | from_yaml if matrix_appservice_kakaotalk_configuration_extension_yaml | from_yaml is mapping else {} }}"
|
||||
|
||||
# Holds the final configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_appservice_kakaotalk_configuration_yaml`.
|
||||
matrix_appservice_kakaotalk_configuration: "{{ matrix_appservice_kakaotalk_configuration_yaml | from_yaml | combine(matrix_appservice_kakaotalk_configuration_extension, recursive=True) }}"
|
||||
|
||||
|
||||
# Default configuration template which covers the generic use case.
|
||||
# You can customize it by controlling the various variables inside it.
|
||||
#
|
||||
# For a more advanced customization, you can extend the default (see `matrix_appservice_kakaotalk_node_configuration_extension_yaml`)
|
||||
# or completely replace this variable with your own template.
|
||||
#
|
||||
# The side-effect of this lookup is that Ansible would even parse the JSON for us, returning a dict.
|
||||
# This is unlike what it does when looking up YAML template files (no automatic parsing there).
|
||||
matrix_appservice_kakaotalk_node_configuration_default: "{{ lookup('template', 'templates/node-config.json.j2') }}"
|
||||
|
||||
# Your custom JSON configuration for appservice-kakaotalk-node should go to `matrix_appservice_kakaotalk_node_configuration_extension_json`.
|
||||
# This configuration extends the default starting configuration (`matrix_appservice_kakaotalk_node_configuration_default`).
|
||||
#
|
||||
# You can override individual variables from the default configuration, or introduce new ones.
|
||||
#
|
||||
# If you need something more special, you can take full control by
|
||||
# completely redefining `matrix_appservice_kakaotalk_node_configuration_default`.
|
||||
#
|
||||
# Example configuration extension follows:
|
||||
#
|
||||
# matrix_appservice_kakaotalk_node_configuration_extension_json: |
|
||||
# {
|
||||
# "register_timeout": 5000
|
||||
# }
|
||||
matrix_appservice_kakaotalk_node_configuration_extension_json: '{}'
|
||||
|
||||
matrix_appservice_kakaotalk_node_configuration_extension: "{{ matrix_appservice_kakaotalk_node_configuration_extension_json | from_json if matrix_appservice_kakaotalk_node_configuration_extension_json | from_json is mapping else {} }}"
|
||||
|
||||
# Holds the final appservice-kakaotalk-node configuration (a combination of the default and its extension).
|
||||
# You most likely don't need to touch this variable. Instead, see `matrix_appservice_kakaotalk_node_configuration_default`.
|
||||
matrix_appservice_kakaotalk_node_configuration: "{{ matrix_appservice_kakaotalk_node_configuration_default | combine(matrix_appservice_kakaotalk_node_configuration_extension, recursive=True) }}"
|
||||
|
||||
|
||||
matrix_appservice_kakaotalk_registration_yaml: |
|
||||
id: appservice-kakaotalk
|
||||
as_token: {{ matrix_appservice_kakaotalk_appservice_token | to_json }}
|
||||
hs_token: {{ matrix_appservice_kakaotalk_homeserver_token | to_json }}
|
||||
namespaces:
|
||||
users:
|
||||
- exclusive: true
|
||||
regex: '^@{{ matrix_appservice_kakaotalk_user_prefix | regex_escape }}.*:{{ matrix_appservice_kakaotalk_homeserver_domain | regex_escape }}$'
|
||||
- exclusive: true
|
||||
regex: '^@{{ matrix_appservice_kakaotalk_appservice_bot_username | regex_escape }}:{{ matrix_appservice_kakaotalk_homeserver_domain | regex_escape }}$'
|
||||
url: {{ matrix_appservice_kakaotalk_appservice_address | to_json }}
|
||||
sender_localpart: _appservice_kakaotalk
|
||||
rate_limited: false
|
||||
|
||||
matrix_appservice_kakaotalk_registration: "{{ matrix_appservice_kakaotalk_registration_yaml | from_yaml }}"
|
28
roles/matrix-bridge-appservice-kakaotalk/tasks/init.yml
Normal file
28
roles/matrix-bridge-appservice-kakaotalk/tasks/init.yml
Normal file
@ -0,0 +1,28 @@
|
||||
---
|
||||
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
|
||||
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
|
||||
- name: Fail if trying to self-build on Ansible < 2.8
|
||||
ansible.builtin.fail:
|
||||
msg: "To self-build the appservice-kakaotalk image, you should use Ansible 2.8 or higher. See docs/ansible.md"
|
||||
when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_kakaotalk_container_image_self_build and matrix_appservice_kakaotalk_enabled"
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-kakaotalk.service', 'matrix-appservice-kakaotalk-node.service'] }}"
|
||||
when: matrix_appservice_kakaotalk_enabled | bool
|
||||
|
||||
# If the matrix-synapse role is not used, these variables may not exist.
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_synapse_container_extra_arguments: >
|
||||
{{
|
||||
matrix_synapse_container_extra_arguments | default([])
|
||||
+
|
||||
["--mount type=bind,src={{ matrix_appservice_kakaotalk_config_path }}/registration.yaml,dst=/matrix-appservice-kakaotalk-registration.yaml,ro"]
|
||||
}}
|
||||
|
||||
matrix_synapse_app_service_config_files: >
|
||||
{{
|
||||
matrix_synapse_app_service_config_files | default([])
|
||||
+
|
||||
["/matrix-appservice-kakaotalk-registration.yaml"]
|
||||
}}
|
||||
when: matrix_appservice_kakaotalk_enabled | bool
|
23
roles/matrix-bridge-appservice-kakaotalk/tasks/main.yml
Normal file
23
roles/matrix-bridge-appservice-kakaotalk/tasks/main.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: "run_setup | bool and matrix_appservice_kakaotalk_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-kakaotalk
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: "run_setup | bool and matrix_appservice_kakaotalk_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-kakaotalk
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: "run_setup | bool and not matrix_appservice_kakaotalk_enabled | bool"
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-appservice-kakaotalk
|
125
roles/matrix-bridge-appservice-kakaotalk/tasks/setup_install.yml
Normal file
125
roles/matrix-bridge-appservice-kakaotalk/tasks/setup_install.yml
Normal file
@ -0,0 +1,125 @@
|
||||
---
|
||||
|
||||
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
|
||||
# We don't want to fail in such cases.
|
||||
- name: Fail if matrix-synapse role already executed
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
The matrix-bridge-matrix-appservice-kakaotalk role needs to execute before the matrix-synapse role.
|
||||
when: "matrix_synapse_role_executed | default(False)"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_appservice_kakaotalk_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_appservice_kakaotalk_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_kakaotalk_docker_image_force_pull }}"
|
||||
when: not matrix_appservice_kakaotalk_container_image_self_build
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk-node image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_appservice_kakaotalk_node_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_appservice_kakaotalk_node_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_kakaotalk_node_docker_image_force_pull }}"
|
||||
when: not matrix_appservice_kakaotalk_container_image_self_build
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_appservice_kakaotalk_base_path }}", when: true}
|
||||
- {path: "{{ matrix_appservice_kakaotalk_config_path }}", when: true}
|
||||
- {path: "{{ matrix_appservice_kakaotalk_data_path }}", when: true}
|
||||
- {path: "{{ matrix_appservice_kakaotalk_docker_src_files_path }}", when: "{{ matrix_appservice_kakaotalk_container_image_self_build }}"}
|
||||
when: item.when | bool
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk repository is present on self-build
|
||||
ansible.builtin.git:
|
||||
repo: "{{ matrix_appservice_kakaotalk_container_image_self_build_repo }}"
|
||||
dest: "{{ matrix_appservice_kakaotalk_docker_src_files_path }}"
|
||||
version: "{{ matrix_appservice_kakaotalk_container_image_self_build_repo_version }}"
|
||||
force: "yes"
|
||||
become: true
|
||||
become_user: "{{ matrix_user_username }}"
|
||||
register: matrix_appservice_kakaotalk_git_pull_results
|
||||
when: "matrix_appservice_kakaotalk_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk-node Docker image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_appservice_kakaotalk_node_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_appservice_kakaotalk_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_kakaotalk_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_appservice_kakaotalk_docker_src_files_path }}/node"
|
||||
pull: true
|
||||
when: "matrix_appservice_kakaotalk_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk Docker image is built
|
||||
docker_image:
|
||||
name: "{{ matrix_appservice_kakaotalk_docker_image }}"
|
||||
source: build
|
||||
force_source: "{{ matrix_appservice_kakaotalk_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_kakaotalk_git_pull_results.changed }}"
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
path: "{{ matrix_appservice_kakaotalk_docker_src_files_path }}"
|
||||
pull: true
|
||||
when: "matrix_appservice_kakaotalk_container_image_self_build | bool"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk-node config.json installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_kakaotalk_node_configuration | to_nice_json }}"
|
||||
dest: "{{ matrix_appservice_kakaotalk_config_path }}/node-config.json"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk config.yaml installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_kakaotalk_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_kakaotalk_config_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk registration.yaml installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_kakaotalk_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_kakaotalk_config_path }}/registration.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk-node.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-appservice-kakaotalk-node.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk-node.service"
|
||||
mode: 0644
|
||||
register: matrix_appservice_kakaotalk_node_systemd_service_result
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-appservice-kakaotalk.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk.service"
|
||||
mode: 0644
|
||||
register: matrix_appservice_kakaotalk_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-kakaotalk.service or matrix-appservice-kakaotalk-node.service installation
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: matrix_appservice_kakaotalk_node_systemd_service_result.changed or matrix_appservice_kakaotalk_systemd_service_result.changed
|
@ -0,0 +1,41 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-appservice-kakaotalk service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk.service"
|
||||
register: matrix_appservice_kakaotalk_service_stat
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-kakaotalk
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_kakaotalk_service_stat.stat.exists"
|
||||
|
||||
- name: Check existence of matrix-appservice-kakaotalk-node service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk-node.service"
|
||||
register: matrix_appservice_kakaotalk_node_service_stat
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk-node is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-appservice-kakaotalk-node
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_kakaotalk_node_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-appservice-kakaotalk.service files don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk-node.service"
|
||||
- "{{ matrix_systemd_path }}/matrix-appservice-kakaotalk.service"
|
||||
when: "matrix_appservice_kakaotalk_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-appservice-kakaotalk service files removal
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_kakaotalk_service_stat.stat.exists or matrix_appservice_kakaotalk_node_service_stat.stat.exists"
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
- name: Fail if required settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- "matrix_appservice_kakaotalk_appservice_token"
|
||||
- "matrix_appservice_kakaotalk_homeserver_token"
|
@ -0,0 +1,276 @@
|
||||
# Homeserver details
|
||||
homeserver:
|
||||
# The address that this appservice can use to connect to the homeserver.
|
||||
address: {{ matrix_appservice_kakaotalk_homeserver_address | to_json }}
|
||||
# The domain of the homeserver (for MXIDs, etc).
|
||||
domain: {{ matrix_appservice_kakaotalk_homeserver_domain | to_json }}
|
||||
# Whether or not to verify the SSL certificate of the homeserver.
|
||||
# Only applies if address starts with https://
|
||||
verify_ssl: true
|
||||
# Whether or not the homeserver supports asmux-specific endpoints,
|
||||
# such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically
|
||||
# updating m.direct.
|
||||
asmux: false
|
||||
# Number of retries for all HTTP requests if the homeserver isn't reachable.
|
||||
http_retry_count: 4
|
||||
# The URL to push real-time bridge status to.
|
||||
# If set, the bridge will make POST requests to this URL whenever a user's MQTT connection state changes.
|
||||
# The bridge will use the appservice as_token to authorize requests.
|
||||
status_endpoint: null
|
||||
# Endpoint for reporting per-message status.
|
||||
message_send_checkpoint_endpoint: null
|
||||
# Whether asynchronous uploads via MSC2246 should be enabled for media.
|
||||
# Requires a media repo that supports MSC2246.
|
||||
async_media: false
|
||||
|
||||
# Application service host/registration related details
|
||||
# Changing these values requires regeneration of the registration.
|
||||
appservice:
|
||||
# The address that the homeserver can use to connect to this appservice.
|
||||
address: {{ matrix_appservice_kakaotalk_appservice_address | to_json }}
|
||||
|
||||
# The hostname and port where this appservice should listen.
|
||||
hostname: 0.0.0.0
|
||||
port: 11115
|
||||
# The maximum body size of appservice API requests (from the homeserver) in mebibytes
|
||||
# Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s
|
||||
max_body_size: 1
|
||||
|
||||
# The full URI to the database. SQLite and Postgres are supported.
|
||||
# Format examples:
|
||||
# SQLite: sqlite:///filename.db
|
||||
# Postgres: postgres://username:password@hostname/dbname
|
||||
database: {{ matrix_appservice_kakaotalk_appservice_database | to_json }}
|
||||
# Additional arguments for asyncpg.create_pool() or sqlite3.connect()
|
||||
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
|
||||
# https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
|
||||
# For sqlite, min_size is used as the connection thread pool size and max_size is ignored.
|
||||
database_opts:
|
||||
min_size: 5
|
||||
max_size: 10
|
||||
|
||||
# The unique ID of this appservice.
|
||||
id: appservice-kakaotalk
|
||||
# Username of the appservice bot.
|
||||
bot_username: {{ matrix_appservice_kakaotalk_appservice_bot_username | to_json }}
|
||||
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
|
||||
# to leave display name/avatar as-is.
|
||||
bot_displayname: KakaoTalk bridge bot
|
||||
bot_avatar:
|
||||
|
||||
# Whether or not to receive ephemeral events via appservice transactions.
|
||||
# Requires MSC2409 support (i.e. Synapse 1.22+).
|
||||
# You should disable bridge -> sync_with_custom_puppets when this is enabled.
|
||||
ephemeral_events: false
|
||||
|
||||
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
|
||||
as_token: {{ matrix_appservice_kakaotalk_appservice_token | to_json }}
|
||||
hs_token: {{ matrix_appservice_kakaotalk_homeserver_token | to_json }}
|
||||
|
||||
# Prometheus telemetry config. Requires prometheus-client to be installed.
|
||||
metrics:
|
||||
enabled: false
|
||||
listen_port: 8000
|
||||
|
||||
# Manhole config.
|
||||
manhole:
|
||||
# Whether or not opening the manhole is allowed.
|
||||
enabled: false
|
||||
# The path for the unix socket.
|
||||
path: /var/tmp/matrix-appservice-kakaotalk.manhole
|
||||
# The list of UIDs who can be added to the whitelist.
|
||||
# If empty, any UIDs can be specified in the open-manhole command.
|
||||
whitelist:
|
||||
- 0
|
||||
|
||||
# Config for things that are directly sent to KakaoTalk.
|
||||
kakaotalk:
|
||||
device_name: "KakaoTalk Bridge"
|
||||
|
||||
# Bridge config
|
||||
bridge:
|
||||
# Localpart template of MXIDs for KakaoTalk users.
|
||||
# {userid} is replaced with the user ID of the KakaoTalk user.
|
||||
username_template: "{{ matrix_appservice_kakaotalk_user_prefix }}{userid}"
|
||||
# Displayname template for KakaoTalk users.
|
||||
# {displayname} is replaced with the display name of the KakaoTalk user.
|
||||
displayname_template: "{displayname} (KT)"
|
||||
|
||||
# The prefix for commands. Only required in non-management rooms.
|
||||
command_prefix: {{ matrix_appservice_kakaotalk_command_prefix | to_json }}
|
||||
|
||||
# Number of chats to sync (and create portals for) on startup/login.
|
||||
# Set to 0 to disable automatic syncing, or -1 to sync as much as possible.
|
||||
initial_chat_sync: 20
|
||||
# Whether or not the KakaoTalk users of logged in Matrix users should be
|
||||
# invited to private chats when the user sends a message from another client.
|
||||
invite_own_puppet_to_pm: false
|
||||
# Whether or not to use /sync to get presence, read receipts and typing notifications
|
||||
# when double puppeting is enabled
|
||||
sync_with_custom_puppets: true
|
||||
# Whether or not to update the m.direct account data event when double puppeting is enabled.
|
||||
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
|
||||
# and is therefore prone to race conditions.
|
||||
sync_direct_chat_list: false
|
||||
# Servers to always allow double puppeting from
|
||||
double_puppet_server_map: {}
|
||||
# Allow using double puppeting from any server with a valid client .well-known file.
|
||||
double_puppet_allow_discovery: false
|
||||
# Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth
|
||||
#
|
||||
# If set, custom puppets will be enabled automatically for local users
|
||||
# instead of users having to find an access token and run `login-matrix`
|
||||
# manually.
|
||||
# If using this for other servers than the bridge's server,
|
||||
# you must also set the URL in the double_puppet_server_map.
|
||||
login_shared_secret_map: {{ matrix_appservice_kakaotalk_bridge_login_shared_secret_map | to_json }}
|
||||
# Whether or not to update avatars when syncing all contacts at startup.
|
||||
update_avatar_initial_sync: true
|
||||
# End-to-bridge encryption support options. These require matrix-nio to be installed with pip
|
||||
# and login_shared_secret to be configured in order to get a device for the bridge bot.
|
||||
#
|
||||
# Additionally, https://github.com/matrix-org/synapse/pull/5758 is required if using a normal
|
||||
# application service.
|
||||
encryption:
|
||||
# Allow encryption, work in group chat rooms with e2ee enabled
|
||||
allow: {{ matrix_appservice_kakaotalk_bridge_encryption_allow | to_json }}
|
||||
# Default to encryption, force-enable encryption in all portals the bridge creates
|
||||
# This will cause the bridge bot to be in private chats for the encryption to work properly.
|
||||
default: {{ matrix_appservice_kakaotalk_bridge_encryption_default| to_json }}
|
||||
# Options for automatic key sharing.
|
||||
key_sharing:
|
||||
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
|
||||
# You must use a client that supports requesting keys from other users to use this feature.
|
||||
allow: false
|
||||
# Require the requesting device to have a valid cross-signing signature?
|
||||
# This doesn't require that the bridge has verified the device, only that the user has verified it.
|
||||
# Not yet implemented.
|
||||
require_cross_signing: false
|
||||
# Require devices to be verified by the bridge?
|
||||
# Verification by the bridge is not yet implemented.
|
||||
require_verification: true
|
||||
# Whether or not the bridge should send a read receipt from the bridge bot when a message has
|
||||
# been sent to KakaoTalk.
|
||||
delivery_receipts: false
|
||||
# Whether to allow inviting arbitrary mxids to portal rooms
|
||||
allow_invites: false
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
federate_rooms: {{ matrix_appservice_kakaotalk_federate_rooms | to_json }}
|
||||
# Settings for backfilling messages from KakaoTalk.
|
||||
backfill:
|
||||
# Whether or not the KakaoTalk users of logged in Matrix users should be
|
||||
# invited to private chats when backfilling history from KakaoTalk. This is
|
||||
# usually needed to prevent rate limits and to allow timestamp massaging.
|
||||
invite_own_puppet: true
|
||||
# Maximum number of messages to backfill initially.
|
||||
# Set to 0 to disable backfilling when creating portal, or -1 to backfill as much as possible.
|
||||
initial_limit: 0
|
||||
# Maximum number of messages to backfill if messages were missed while
|
||||
# the bridge was disconnected.
|
||||
# Set to 0 to disable backfilling missed messages, or -1 to backfill as much as possible.
|
||||
missed_limit: 1000
|
||||
# If using double puppeting, should notifications be disabled
|
||||
# while the initial backfill is in progress?
|
||||
disable_notifications: false
|
||||
# The number of seconds that a disconnection can last without triggering an automatic re-sync
|
||||
# and missed message backfilling when reconnecting.
|
||||
# Set to 0 to always re-sync, or -1 to never re-sync automatically.
|
||||
resync_max_disconnected_time: 5
|
||||
# Should users remain logged in after being disconnected from chatroom updates?
|
||||
# This is a convenience feature, but might make the bridge look more suspicious to KakaoTalk.
|
||||
remain_logged_in_on_disconnect: true
|
||||
# May the bridge restore user logins with session tokens instead of requiring a password?
|
||||
# This is a convenience feature, but might make the bridge look more suspicious to KakaoTalk.
|
||||
# Note that password-based login will be tried first for users who have saved their password.
|
||||
allow_token_relogin: true
|
||||
# Should the bridge connect users to chatroom updates after a token-based login?
|
||||
# This will disconnect any KakaoTalk PC/bridge sessions that were started since the last connection.
|
||||
# This is a convenience feature, but might make the bridge look more suspicious to KakaoTalk.
|
||||
reconnect_on_token_relogin: true
|
||||
# Should the bridge do a resync for connected users on startup?
|
||||
sync_on_startup: true
|
||||
# Whether or not temporary disconnections should send notices to the notice room.
|
||||
# If this is false, disconnections will never send messages and connections will only send
|
||||
# messages if it was disconnected for more than resync_max_disconnected_time seconds.
|
||||
temporary_disconnect_notices: true
|
||||
# Disable bridge notices entirely
|
||||
disable_bridge_notices: false
|
||||
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
|
||||
# This field will automatically be changed back to false after it,
|
||||
# except if the config file is not writable.
|
||||
resend_bridge_info: false
|
||||
# Whether or not mute status and tags should only be bridged when the portal room is created.
|
||||
tag_only_on_create: true
|
||||
# If set to true, downloading media from the CDN will use a plain aiohttp client without the usual headers or
|
||||
# other configuration. This may be useful if you don't want to use the default proxy for large files.
|
||||
sandbox_media_download: false
|
||||
|
||||
# Permissions for using the bridge.
|
||||
# Permitted values:
|
||||
# relay - Allowed to be relayed through the bridge, no access to commands.
|
||||
# user - Use the bridge with puppeting.
|
||||
# admin - Use and administrate the bridge.
|
||||
# Permitted keys:
|
||||
# * - All Matrix users
|
||||
# domain - All users on that homeserver
|
||||
# mxid - Specific user
|
||||
permissions: {{ matrix_appservice_kakaotalk_bridge_permissions | to_json }}
|
||||
|
||||
relay:
|
||||
# Whether relay mode should be allowed. If allowed, `!kt set-relay` can be used to turn any
|
||||
# authenticated user into a relaybot for that chat.
|
||||
enabled: false
|
||||
# The formats to use when sending messages to KakaoTalk via a relay user.
|
||||
#
|
||||
# Available variables:
|
||||
# $sender_displayname - The display name of the sender (e.g. Example User)
|
||||
# $sender_username - The username (Matrix ID localpart) of the sender (e.g. exampleuser)
|
||||
# $sender_mxid - The Matrix ID of the sender (e.g. @exampleuser:example.com)
|
||||
# $message - The message content
|
||||
message_formats:
|
||||
m.text: '<b>$sender_displayname</b>: $message'
|
||||
m.notice: '<b>$sender_displayname<b>: $message'
|
||||
m.emote: '* <b>$sender_displayname<b> $message'
|
||||
m.file: 'File from <b>$sender_displayname</b>: $message'
|
||||
m.image: 'Image from <b>$sender_displayname</b>: $message'
|
||||
m.audio: 'Audio from <b>$sender_displayname</b>: $message'
|
||||
m.video: 'Video from <b>$sender_displayname</b>: $message'
|
||||
m.location: '<b>$sender_displayname</b> sent a location'
|
||||
|
||||
rpc:
|
||||
connection:
|
||||
# Either unix or tcp
|
||||
type: tcp
|
||||
# Only for type: unix
|
||||
# path: /rpc/rpc.sock
|
||||
# Only for type: tcp
|
||||
host: matrix-appservice-kakaotalk-node
|
||||
port: 8000
|
||||
|
||||
# Python logging configuration.
|
||||
#
|
||||
# See section 16.7.2 of the Python documentation for more info:
|
||||
# https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema
|
||||
logging:
|
||||
version: 1
|
||||
formatters:
|
||||
colored:
|
||||
(): matrix_appservice_kakaotalk.util.ColorFormatter
|
||||
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
|
||||
normal:
|
||||
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
formatter: colored
|
||||
loggers:
|
||||
mau:
|
||||
level: {{ matrix_appservice_kakaotalk_logging_level | to_json }}
|
||||
paho:
|
||||
level: {{ matrix_appservice_kakaotalk_logging_level | to_json }}
|
||||
aiohttp:
|
||||
level: {{ matrix_appservice_kakaotalk_logging_level | to_json }}
|
||||
root:
|
||||
level: {{ matrix_appservice_kakaotalk_logging_level | to_json }}
|
||||
handlers: [console]
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"listen": {
|
||||
"type": "tcp",
|
||||
"host": "0.0.0.0",
|
||||
"port": 8000,
|
||||
"force": false
|
||||
},
|
||||
"register_timeout": 3000,
|
||||
"logging_keys": {
|
||||
"request": ["mxid"],
|
||||
"response": ["status"]
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=appservice-kakaotalk-node bridge helper
|
||||
{% for service in matrix_appservice_kakaotalk_node_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_appservice_kakaotalk_node_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ matrix_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-kakaotalk-node 2>/dev/null || true'
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-kakaotalk-node 2>/dev/null || true'
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-kakaotalk-node \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--network={{ matrix_docker_network }} \
|
||||
--mount type=bind,src={{ matrix_appservice_kakaotalk_config_path }}/node-config.json,dst=/config.json,ro \
|
||||
{% for arg in matrix_appservice_kakaotalk_node_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_appservice_kakaotalk_node_docker_image }} \
|
||||
node src/main.js --config /config.json
|
||||
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-kakaotalk-node 2>/dev/null || true'
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-kakaotalk-node 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-appservice-kakaotalk-node
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,42 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=appservice-kakaotalk bridge
|
||||
{% for service in matrix_appservice_kakaotalk_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_appservice_kakaotalk_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ matrix_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-kakaotalk 2>/dev/null || true'
|
||||
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-kakaotalk 2>/dev/null || true'
|
||||
|
||||
# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
|
||||
ExecStartPre={{ matrix_host_command_sleep }} 5
|
||||
|
||||
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-kakaotalk \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--network={{ matrix_docker_network }} \
|
||||
--mount type=bind,src={{ matrix_appservice_kakaotalk_config_path }},dst=/config,ro \
|
||||
--mount type=bind,src={{ matrix_appservice_kakaotalk_data_path }},dst=/data \
|
||||
{% for arg in matrix_appservice_kakaotalk_container_extra_arguments %}
|
||||
{{ arg }} \
|
||||
{% endfor %}
|
||||
{{ matrix_appservice_kakaotalk_docker_image }} \
|
||||
python3 -m matrix_appservice_kakaotalk -c /config/config.yaml --no-update
|
||||
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-kakaotalk 2>/dev/null || true'
|
||||
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-kakaotalk 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-appservice-kakaotalk
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,15 +1,19 @@
|
||||
---
|
||||
# matrix-appservice-slack is a Matrix <-> Slack bridge
|
||||
# See: https://github.com/matrix-org/matrix-appservice-slack
|
||||
# Project source code URL: https://github.com/matrix-org/matrix-appservice-slack
|
||||
|
||||
matrix_appservice_slack_enabled: true
|
||||
|
||||
matrix_appservice_slack_container_image_self_build: false
|
||||
matrix_appservice_slack_docker_repo: "https://github.com/matrix-org/matrix-appservice-slack.git"
|
||||
matrix_appservice_slack_docker_repo_version: "{{ 'master' if matrix_appservice_slack_version == 'latest' else matrix_appservice_slack_version }}"
|
||||
matrix_appservice_slack_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-slack/docker-src"
|
||||
|
||||
matrix_appservice_slack_version: release-1.10.0
|
||||
matrix_appservice_slack_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-slack:{{ matrix_appservice_slack_version }}"
|
||||
# matrix_appservice_slack_version used to contain the full Docker image tag (e.g. `release-X.X.X`).
|
||||
# It's a bare version number now. We try to somewhat retain compatibility below.
|
||||
matrix_appservice_slack_version: 1.11.0
|
||||
matrix_appservice_slack_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-slack:{{ matrix_appservice_slack_docker_image_tag }}"
|
||||
matrix_appservice_slack_docker_image_tag: "{{ 'latest' if matrix_appservice_slack_version == 'latest' else ('release-' + matrix_appservice_slack_version) }}"
|
||||
matrix_appservice_slack_docker_image_force_pull: "{{ matrix_appservice_slack_docker_image.endswith(':latest') }}"
|
||||
|
||||
matrix_appservice_slack_base_path: "{{ matrix_base_data_path }}/appservice-slack"
|
||||
@ -63,12 +67,13 @@ matrix_appservice_slack_database_name: matrix_appservice_slack
|
||||
matrix_appservice_slack_database_connection_string: 'postgresql://{{ matrix_appservice_slack_database_username }}:{{ matrix_appservice_slack_database_password }}@{{ matrix_appservice_slack_database_hostname }}:{{ matrix_appservice_slack_database_port }}/{{ matrix_appservice_slack_database_name }}?sslmode=disable'
|
||||
|
||||
# This is what actually goes into `database.connectionString` for the bridge.
|
||||
matrix_appservice_slack_database_connectionString: "{{
|
||||
{
|
||||
'nedb': 'nedb:///data',
|
||||
'postgres': matrix_appservice_slack_database_connection_string,
|
||||
}[matrix_appservice_slack_database_engine]
|
||||
}}"
|
||||
matrix_appservice_slack_database_connectionString: |- # noqa var-naming
|
||||
{{
|
||||
{
|
||||
'nedb': 'nedb:///data',
|
||||
'postgres': matrix_appservice_slack_database_connection_string,
|
||||
}[matrix_appservice_slack_database_engine]
|
||||
}}
|
||||
|
||||
|
||||
matrix_appservice_slack_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"
|
||||
@ -95,9 +100,9 @@ matrix_appservice_slack_configuration_extension_yaml: |
|
||||
# - "./debug.log": "info"
|
||||
#- "./error.log": "error"
|
||||
|
||||
matrix_appservice_slack_configuration_extension: "{{ matrix_appservice_slack_configuration_extension_yaml|from_yaml if matrix_appservice_slack_configuration_extension_yaml|from_yaml else {} }}"
|
||||
matrix_appservice_slack_configuration_extension: "{{ matrix_appservice_slack_configuration_extension_yaml | from_yaml if matrix_appservice_slack_configuration_extension_yaml | from_yaml else {} }}"
|
||||
|
||||
matrix_appservice_slack_configuration: "{{ matrix_appservice_slack_configuration_yaml|from_yaml|combine(matrix_appservice_slack_configuration_extension, recursive=True) }}"
|
||||
matrix_appservice_slack_configuration: "{{ matrix_appservice_slack_configuration_yaml | from_yaml | combine(matrix_appservice_slack_configuration_extension, recursive=True) }}"
|
||||
|
||||
matrix_appservice_slack_registration_yaml: |
|
||||
id: "{{ matrix_appservice_slack_id_token }}"
|
||||
@ -111,9 +116,9 @@ matrix_appservice_slack_registration_yaml: |
|
||||
- exclusive: false
|
||||
regex: '#{{ matrix_appservice_slack_user_prefix }}.*'
|
||||
rooms: []
|
||||
url: "{{matrix_appservice_slack_appservice_url}}:{{ matrix_appservice_slack_matrix_port }}"
|
||||
url: "{{ matrix_appservice_slack_appservice_url }}:{{ matrix_appservice_slack_matrix_port }}"
|
||||
sender_localpart: slackbot
|
||||
rate_limited: true
|
||||
protocols: null
|
||||
|
||||
matrix_appservice_slack_registration: "{{ matrix_appservice_slack_registration_yaml|from_yaml }}"
|
||||
matrix_appservice_slack_registration: "{{ matrix_appservice_slack_registration_yaml | from_yaml }}"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user