Merge pull request #1948 from spantaleev/ansible-lint-fixes

Ansible lint fixes
This commit is contained in:
Slavi Pantaleev 2022-07-18 17:08:21 +03:00 committed by GitHub
commit cbada7341d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
430 changed files with 3623 additions and 3412 deletions

13
.config/ansible-lint.yml Normal file
View File

@ -0,0 +1,13 @@
---
use_default_rules: true
skip_list:
- unnamed-task
- no-handler
- no-jinja-nesting
- schema
- command-instead-of-shell
- role-name
offline: false

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
.PHONY: lint
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
lint: ## Runs ansible-lint against all roles in the playbook
ansible-lint

View File

@ -22,16 +22,16 @@ matrix_identity_server_url: "{{ ('https://' + matrix_server_fqn_matrix) if matri
matrix_homeserver_container_url: |- matrix_homeserver_container_url: |-
{{ {{
'http://matrix-nginx-proxy:12080' if matrix_nginx_proxy_enabled else { 'http://matrix-nginx-proxy:12080' if matrix_nginx_proxy_enabled else {
'synapse': ('http://matrix-synapse:'+ matrix_synapse_container_client_api_port|string), 'synapse': ('http://matrix-synapse:'+ matrix_synapse_container_client_api_port | string),
'dendrite': ('http://matrix-dendrite:' + matrix_dendrite_http_bind_port|string), 'dendrite': ('http://matrix-dendrite:' + matrix_dendrite_http_bind_port | string),
}[matrix_homeserver_implementation] }[matrix_homeserver_implementation]
}} }}
matrix_homeserver_container_federation_url: |- matrix_homeserver_container_federation_url: |-
{{ {{
'http://matrix-nginx-proxy:12088' if matrix_nginx_proxy_enabled else { 'http://matrix-nginx-proxy:12088' if matrix_nginx_proxy_enabled else {
'synapse': ('http://matrix-synapse:'+ matrix_synapse_container_federation_api_plain_port|string), 'synapse': ('http://matrix-synapse:'+ matrix_synapse_container_federation_api_plain_port | string),
'dendrite': ('http://matrix-dendrite:' + matrix_dendrite_http_bind_port|string), 'dendrite': ('http://matrix-dendrite:' + matrix_dendrite_http_bind_port | string),
}[matrix_homeserver_implementation] }[matrix_homeserver_implementation]
}} }}
@ -1158,7 +1158,7 @@ matrix_backup_borg_postgresql_databases: |
'name': matrix_synapse_database_database 'name': matrix_synapse_database_database
}] if (matrix_synapse_enabled and matrix_synapse_database_database == matrix_postgres_db_name and matrix_synapse_database_host == 'matrix-postgres') else []) }] if (matrix_synapse_enabled and matrix_synapse_database_database == matrix_postgres_db_name and matrix_synapse_database_host == 'matrix-postgres') else [])
+ +
matrix_postgres_additional_databases)|map(attribute='name')|list matrix_postgres_additional_databases)|map(attribute='name') | list
}} }}
matrix_backup_borg_location_source_directories: matrix_backup_borg_location_source_directories:
- "{{ matrix_base_data_path }}" - "{{ matrix_base_data_path }}"
@ -1431,7 +1431,7 @@ matrix_ma1sd_container_image_self_build: "{{ matrix_architecture != 'amd64' }}"
# Normally, matrix-nginx-proxy is enabled and nginx can reach ma1sd over the container network. # Normally, matrix-nginx-proxy is enabled and nginx can reach ma1sd over the container network.
# If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, you can expose # If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, you can expose
# ma1sd's web-server port. # ma1sd's web-server port.
matrix_ma1sd_container_http_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_ma1sd_container_port|string }}" matrix_ma1sd_container_http_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_ma1sd_container_port | string }}"
# We enable Synapse integration via its Postgres database by default. # We enable Synapse integration via its Postgres database by default.
@ -1540,14 +1540,14 @@ matrix_nginx_proxy_proxy_matrix_federation_api_addr_sans_container: "127.0.0.1:1
matrix_nginx_proxy_proxy_synapse_enabled: "{{ matrix_synapse_enabled }}" matrix_nginx_proxy_proxy_synapse_enabled: "{{ matrix_synapse_enabled }}"
matrix_nginx_proxy_proxy_synapse_client_api_addr_with_container: "matrix-synapse:{{ matrix_synapse_container_client_api_port }}" matrix_nginx_proxy_proxy_synapse_client_api_addr_with_container: "matrix-synapse:{{ matrix_synapse_container_client_api_port }}"
matrix_nginx_proxy_proxy_synapse_client_api_addr_sans_container: "127.0.0.1:{{ matrix_synapse_container_client_api_port }}" matrix_nginx_proxy_proxy_synapse_client_api_addr_sans_container: "127.0.0.1:{{ matrix_synapse_container_client_api_port }}"
matrix_nginx_proxy_proxy_synapse_federation_api_addr_with_container: "matrix-synapse:{{matrix_synapse_container_federation_api_plain_port|string}}" matrix_nginx_proxy_proxy_synapse_federation_api_addr_with_container: "matrix-synapse:{{matrix_synapse_container_federation_api_plain_port | string}}"
matrix_nginx_proxy_proxy_synapse_federation_api_addr_sans_container: "127.0.0.1:{{matrix_synapse_container_federation_api_plain_port|string}}" matrix_nginx_proxy_proxy_synapse_federation_api_addr_sans_container: "127.0.0.1:{{matrix_synapse_container_federation_api_plain_port | string}}"
matrix_nginx_proxy_proxy_dendrite_enabled: "{{ matrix_dendrite_enabled }}" matrix_nginx_proxy_proxy_dendrite_enabled: "{{ matrix_dendrite_enabled }}"
matrix_nginx_proxy_proxy_dendrite_client_api_addr_with_container: "matrix-dendrite:{{ matrix_dendrite_http_bind_port|string }}" matrix_nginx_proxy_proxy_dendrite_client_api_addr_with_container: "matrix-dendrite:{{ matrix_dendrite_http_bind_port | string }}"
matrix_nginx_proxy_proxy_dendrite_client_api_addr_sans_container: "127.0.0.1:{{ matrix_dendrite_http_bind_port|string }}" matrix_nginx_proxy_proxy_dendrite_client_api_addr_sans_container: "127.0.0.1:{{ matrix_dendrite_http_bind_port | string }}"
matrix_nginx_proxy_proxy_dendrite_federation_api_addr_with_container: "matrix-dendrite:{{ matrix_dendrite_http_bind_port|string }}" matrix_nginx_proxy_proxy_dendrite_federation_api_addr_with_container: "matrix-dendrite:{{ matrix_dendrite_http_bind_port | string }}"
matrix_nginx_proxy_proxy_dendrite_federation_api_addr_sans_container: "127.0.0.1:{{ matrix_dendrite_http_bind_port|string }}" matrix_nginx_proxy_proxy_dendrite_federation_api_addr_sans_container: "127.0.0.1:{{ matrix_dendrite_http_bind_port | string }}"
# When matrix-nginx-proxy is disabled, the actual port number that the vhost uses may begin to matter. # When matrix-nginx-proxy is disabled, the actual port number that the vhost uses may begin to matter.
matrix_nginx_proxy_proxy_matrix_federation_port: "{{ matrix_federation_public_port }}" matrix_nginx_proxy_proxy_matrix_federation_port: "{{ matrix_federation_public_port }}"
@ -1885,14 +1885,14 @@ matrix_postgres_import_roles_to_ignore: |
{{ {{
[matrix_postgres_connection_username] [matrix_postgres_connection_username]
+ +
matrix_postgres_additional_databases|map(attribute='username')|list matrix_postgres_additional_databases|map(attribute='username') | list
}} }}
matrix_postgres_import_databases_to_ignore: | matrix_postgres_import_databases_to_ignore: |
{{ {{
[matrix_postgres_db_name] [matrix_postgres_db_name]
+ +
matrix_postgres_additional_databases|map(attribute='name')|list matrix_postgres_additional_databases|map(attribute='name') | list
}} }}
###################################################################### ######################################################################
@ -2058,18 +2058,18 @@ matrix_synapse_container_image_self_build: "{{ matrix_architecture not in ['arm6
# When ma1sd is enabled, we can use it to validate email addresses and phone numbers. # When ma1sd is enabled, we can use it to validate email addresses and phone numbers.
# Synapse can validate email addresses by itself as well, but it's probably not what we want by default when we have an identity server. # Synapse can validate email addresses by itself as well, but it's probably not what we want by default when we have an identity server.
matrix_synapse_account_threepid_delegates_email: "{{ 'http://matrix-ma1sd:' + matrix_ma1sd_container_port|string if matrix_ma1sd_enabled else '' }}" matrix_synapse_account_threepid_delegates_email: "{{ 'http://matrix-ma1sd:' + matrix_ma1sd_container_port | string if matrix_ma1sd_enabled else '' }}"
matrix_synapse_account_threepid_delegates_msisdn: "{{ 'http://matrix-ma1sd:' + matrix_ma1sd_container_port|string if matrix_ma1sd_enabled else '' }}" matrix_synapse_account_threepid_delegates_msisdn: "{{ 'http://matrix-ma1sd:' + matrix_ma1sd_container_port | string if matrix_ma1sd_enabled else '' }}"
# Normally, matrix-nginx-proxy is enabled and nginx can reach Synapse over the container network. # Normally, matrix-nginx-proxy is enabled and nginx can reach Synapse over the container network.
# If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, # If matrix-nginx-proxy is not enabled, or you otherwise have a need for it,
# you can expose Synapse's ports to the host. # you can expose Synapse's ports to the host.
# #
# For exposing the Matrix Client API's port (plain HTTP) to the local host. # For exposing the Matrix Client API's port (plain HTTP) to the local host.
matrix_synapse_container_client_api_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_synapse_container_client_api_port|string }}" matrix_synapse_container_client_api_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_synapse_container_client_api_port | string }}"
# #
# For exposing the Matrix Federation API's plain port (plain HTTP) to the local host. # For exposing the Matrix Federation API's plain port (plain HTTP) to the local host.
matrix_synapse_container_federation_api_plain_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_synapse_container_federation_api_plain_port|string }}" matrix_synapse_container_federation_api_plain_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_synapse_container_federation_api_plain_port | string }}"
# #
# For exposing the Matrix Federation API's TLS port (HTTPS) to the internet on all network interfaces. # For exposing the Matrix Federation API's TLS port (HTTPS) to the internet on all network interfaces.
matrix_synapse_container_federation_api_tls_host_bind_port: "{{ matrix_federation_public_port if (matrix_synapse_federation_enabled and matrix_synapse_tls_federation_listener_enabled) else '' }}" matrix_synapse_container_federation_api_tls_host_bind_port: "{{ matrix_federation_public_port if (matrix_synapse_federation_enabled and matrix_synapse_tls_federation_listener_enabled) else '' }}"
@ -2213,10 +2213,10 @@ matrix_prometheus_scraper_node_enabled: "{{ matrix_prometheus_node_exporter_enab
matrix_prometheus_scraper_node_targets: "{{ ['matrix-prometheus-node-exporter:9100'] if matrix_prometheus_node_exporter_enabled else [] }}" matrix_prometheus_scraper_node_targets: "{{ ['matrix-prometheus-node-exporter:9100'] if matrix_prometheus_node_exporter_enabled else [] }}"
matrix_prometheus_scraper_postgres_enabled: "{{ matrix_prometheus_postgres_exporter_enabled }}" matrix_prometheus_scraper_postgres_enabled: "{{ matrix_prometheus_postgres_exporter_enabled }}"
matrix_prometheus_scraper_postgres_targets: "{{ ['matrix-prometheus-postgres-exporter:'+ matrix_prometheus_postgres_exporter_port|string] if matrix_prometheus_scraper_postgres_enabled else [] }}" matrix_prometheus_scraper_postgres_targets: "{{ ['matrix-prometheus-postgres-exporter:'+ matrix_prometheus_postgres_exporter_port | string] if matrix_prometheus_scraper_postgres_enabled else [] }}"
matrix_prometheus_scraper_hookshot_enabled: "{{ matrix_hookshot_metrics_enabled|default(false) }}" matrix_prometheus_scraper_hookshot_enabled: "{{ matrix_hookshot_metrics_enabled|default(false) }}"
matrix_prometheus_scraper_hookshot_targets: "{{ [matrix_hookshot_container_url|string +':'+ matrix_hookshot_metrics_port|string] if matrix_hookshot_metrics_enabled else [] }}" matrix_prometheus_scraper_hookshot_targets: "{{ [matrix_hookshot_container_url | string +':'+ matrix_hookshot_metrics_port | string] if matrix_hookshot_metrics_enabled else [] }}"
###################################################################### ######################################################################
# #
@ -2345,7 +2345,7 @@ matrix_postgres_backup_databases: |
'name': matrix_synapse_database_database 'name': matrix_synapse_database_database
}] if (matrix_synapse_enabled and matrix_synapse_database_database == matrix_postgres_db_name and matrix_synapse_database_host == 'matrix-postgres') else []) }] if (matrix_synapse_enabled and matrix_synapse_database_database == matrix_postgres_db_name and matrix_synapse_database_host == 'matrix-postgres') else [])
+ +
matrix_postgres_additional_databases)|map(attribute='name')|list matrix_postgres_additional_databases)|map(attribute='name') | list
}} }}
###################################################################### ######################################################################
@ -2367,10 +2367,10 @@ matrix_dendrite_enabled: "{{ matrix_homeserver_implementation == 'dendrite' }}"
# you can expose Dendrite's ports to the host. # you can expose Dendrite's ports to the host.
# #
# For exposing Dendrite's plain HTTP server to the local host. # For exposing Dendrite's plain HTTP server to the local host.
matrix_dendrite_container_http_host_bind_address: "{{ '' if matrix_nginx_proxy_enabled else ('127.0.0.1:' + matrix_dendrite_http_bind_port|string) }}" matrix_dendrite_container_http_host_bind_address: "{{ '' if matrix_nginx_proxy_enabled else ('127.0.0.1:' + matrix_dendrite_http_bind_port | string) }}"
# #
# For exposing Dendrite's HTTPS server to the local host. # For exposing Dendrite's HTTPS server to the local host.
matrix_dendrite_container_https_host_bind_address: "{{ '' if matrix_nginx_proxy_enabled or not matrix_dendrite_https_bind_port else ('127.0.0.1:' + matrix_dendrite_https_bind_port|string) }}" matrix_dendrite_container_https_host_bind_address: "{{ '' if matrix_nginx_proxy_enabled or not matrix_dendrite_https_bind_port else ('127.0.0.1:' + matrix_dendrite_https_bind_port | string) }}"
matrix_dendrite_sync_api_real_ip_header: "{{ 'X-Forwarded-For' if matrix_nginx_proxy_enabled else '' }}" matrix_dendrite_sync_api_real_ip_header: "{{ 'X-Forwarded-For' if matrix_nginx_proxy_enabled else '' }}"

View File

@ -1,7 +1,7 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/setup.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup.yml"
when: run_stop|bool when: run_stop | bool
tags: tags:
- setup-all - setup-all
- setup-aux-files - setup-aux-files

View File

@ -1,19 +1,19 @@
--- ---
- name: Ensure AUX directories are created - name: Ensure AUX directories are created
file: ansible.builtin.file:
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
state: directory state: directory
owner: "{{ item.owner|default(matrix_user_username) }}" owner: "{{ item.owner | default(matrix_user_username) }}"
group: "{{ item.group|default(matrix_user_groupname) }}" group: "{{ item.group | default(matrix_user_groupname) }}"
mode: "{{ item.mode|default(matrix_aux_directory_default_mode) }}" mode: "{{ item.mode | default(matrix_aux_directory_default_mode) }}"
with_items: "{{ matrix_aux_directory_definitions }}" with_items: "{{ matrix_aux_directory_definitions }}"
- name: Ensure AUX files are created - name: Ensure AUX files are created
copy: ansible.builtin.copy:
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
content: "{{ item.content }}" content: "{{ item.content }}"
owner: "{{ item.owner|default(matrix_user_username) }}" owner: "{{ item.owner | default(matrix_user_username) }}"
group: "{{ item.group|default(matrix_user_groupname) }}" group: "{{ item.group | default(matrix_user_groupname) }}"
mode: "{{ item.mode|default(matrix_aux_file_default_mode) }}" mode: "{{ item.mode | default(matrix_aux_file_default_mode) }}"
with_items: "{{ matrix_aux_file_definitions }}" with_items: "{{ matrix_aux_file_definitions }}"

View File

@ -8,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_container_image_self_build: false
matrix_backup_borg_docker_repo: "https://gitlab.com/etke.cc/borgmatic" 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" 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 # version determined automatically, based on postgres server version (if enabled), otherwise latest is used
matrix_backup_borg_version: "" 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: "{{ 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_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 # A list of extra arguments to pass to the container
matrix_backup_borg_container_extra_arguments: [] matrix_backup_borg_container_extra_arguments: []
@ -93,8 +94,8 @@ matrix_backup_borg_configuration_extension_yaml: |
# If you need something more special, you can take full control by # If you need something more special, you can take full control by
# completely redefining `matrix_backup_borg_configuration_yaml`. # 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). # 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`. # 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) }}"

View File

@ -1,4 +1,4 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-backup-borg.timer'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-backup-borg.timer'] }}"
when: matrix_backup_borg_enabled|bool when: matrix_backup_borg_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_backup_borg_enabled|bool" when: "run_setup | bool and matrix_backup_borg_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-backup-borg - setup-backup-borg
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_backup_borg_enabled|bool" when: "run_setup | bool and matrix_backup_borg_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-backup-borg - setup-backup-borg
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_backup_borg_enabled|bool" when: "run_setup | bool and not matrix_backup_borg_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-backup-borg - setup-backup-borg

View File

@ -1,19 +1,22 @@
--- ---
- block: - block:
- import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/detect_existing_postgres_version.yml" - ansible.builtin.import_role:
name: matrix-postgres
tasks_from: detect_existing_postgres_version
- name: Fail if detected Postgres version is unsupported - 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" 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" when: "matrix_postgres_detected_version not in matrix_backup_borg_supported_postgres_versions"
- name: Set the correct borg backup version to use - name: Set the correct borg backup version to use
set_fact: ansible.builtin.set_fact:
matrix_backup_borg_version: "{{ matrix_postgres_detected_version }}" 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 - name: Ensure borg paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -22,18 +25,18 @@
with_items: with_items:
- {path: "{{ matrix_backup_borg_config_path }}", when: true} - {path: "{{ matrix_backup_borg_config_path }}", when: true}
- {path: "{{ matrix_backup_borg_docker_src_files_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 - name: Ensure borgmatic config is created
copy: ansible.builtin.copy:
content: "{{ matrix_backup_borg_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_backup_borg_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_backup_borg_config_path }}/config.yaml" dest: "{{ matrix_backup_borg_config_path }}/config.yaml"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
mode: 0640 mode: 0640
- name: Ensure borg passwd is created - name: Ensure borg passwd is created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/passwd.j2" src: "{{ role_path }}/templates/passwd.j2"
dest: "{{ matrix_backup_borg_config_path }}/passwd" dest: "{{ matrix_backup_borg_config_path }}/passwd"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -41,7 +44,7 @@
mode: 0640 mode: 0640
- name: Ensure borg ssh key is created - name: Ensure borg ssh key is created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/sshkey.j2" src: "{{ role_path }}/templates/sshkey.j2"
dest: "{{ matrix_backup_borg_config_path }}/sshkey" dest: "{{ matrix_backup_borg_config_path }}/sshkey"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -54,21 +57,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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 register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure borg repository is present on self-build - name: Ensure borg repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_backup_borg_docker_repo }}" repo: "{{ matrix_backup_borg_docker_repo }}"
version: "{{ matrix_backup_borg_docker_repo_version }}"
dest: "{{ matrix_backup_borg_docker_src_files_path }}" dest: "{{ matrix_backup_borg_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_backup_borg_git_pull_results 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 - name: Ensure borg image is built
docker_image: docker_image:
@ -80,33 +84,33 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_backup_borg_docker_src_files_path }}" path: "{{ matrix_backup_borg_docker_src_files_path }}"
pull: true 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 - name: Ensure matrix-backup-borg.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2" src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service" dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
mode: 0644 mode: 0644
register: matrix_backup_borg_systemd_service_result register: matrix_backup_borg_systemd_service_result
- name: Ensure matrix-backup-borg.timer installed - name: Ensure matrix-backup-borg.timer installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2" src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2"
dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer" dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
mode: 0644 mode: 0644
register: matrix_backup_borg_systemd_timer_result register: matrix_backup_borg_systemd_timer_result
- name: Ensure systemd reloaded after matrix-backup-borg.service installation - name: Ensure systemd reloaded after matrix-backup-borg.service installation
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-backup-borg.service enabled
service: ansible.builtin.service:
enabled: true enabled: true
name: matrix-backup-borg.service name: matrix-backup-borg.service
- name: Ensure matrix-backup-borg.timer enabled - name: Ensure matrix-backup-borg.timer enabled
service: ansible.builtin.service:
enabled: true enabled: true
name: matrix-backup-borg.timer name: matrix-backup-borg.timer

View File

@ -1,37 +1,37 @@
--- ---
- name: Check existence of matrix-backup-borg service - name: Check existence of matrix-backup-borg service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-backup-borg.service" path: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
register: matrix_backup_borg_service_stat register: matrix_backup_borg_service_stat
- name: Ensure matrix-backup-borg is stopped - name: Ensure matrix-backup-borg is stopped
service: ansible.builtin.service:
name: matrix-backup-borg name: matrix-backup-borg
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result 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 - name: Ensure matrix-backup-borg.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-backup-borg.service" path: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
state: absent 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 - name: Ensure matrix-backup-borg.timer doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-backup-borg.timer" path: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
state: absent 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 - name: Ensure systemd reloaded after matrix-backup-borg.service removal
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure Matrix borg paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_backup_borg_base_path }}" path: "{{ matrix_backup_borg_base_path }}"
state: absent state: absent

View File

@ -1,6 +1,6 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
@ -9,7 +9,7 @@
- "matrix_backup_borg_location_repositories" - "matrix_backup_borg_location_repositories"
- name: Fail if encryption passphrase is undefined unless repository is unencrypted - name: Fail if encryption passphrase is undefined unless repository is unencrypted
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required passphrase using the `matrix_backup_borg_storage_encryption_passphrase` variable. 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'" when: "matrix_backup_borg_storage_encryption_passphrase == '' and matrix_backup_borg_encryption != 'none'"

View File

@ -134,8 +134,8 @@ matrix_host_command_openssl: "/usr/bin/env openssl"
matrix_host_command_systemctl: "/usr/bin/env systemctl" matrix_host_command_systemctl: "/usr/bin/env systemctl"
matrix_host_command_sh: "/usr/bin/env sh" 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_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_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 }}" matrix_homeserver_url: "https://{{ matrix_server_fqn_matrix }}"
@ -157,7 +157,7 @@ matrix_integration_manager_ui_url: ~
# The domain name where a Jitsi server is self-hosted. # 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. # 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 # 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. # 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. # Setting this to false will update `/.well-known/matrix/client` and tell Element clients to avoid E2EE.
@ -202,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_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). # 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`. # 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. # 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. # You can customize it by controlling the various variables inside the template file that it references.
@ -234,11 +234,11 @@ 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_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). # 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`. # 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. # 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). # This is unlike what it does when looking up YAML template files (no automatic parsing there).
@ -246,11 +246,11 @@ matrix_well_known_matrix_support_configuration_default: "{{ lookup('template', '
matrix_well_known_matrix_support_configuration_extension_json: '{}' 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 {} }}" 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). # 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`. # 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) }}" 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 # The Docker network that all services would be put into
matrix_docker_network: "matrix" matrix_docker_network: "matrix"

View File

@ -1,7 +1,7 @@
--- ---
- name: Get rid of old files and directories - name: Get rid of old files and directories
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
with_items: with_items:

View File

@ -1,34 +1,34 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/sanity_check.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/sanity_check.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/clean_up_old_files.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/clean_up_old_files.yml"
when: run_setup|bool when: run_setup | bool
tags: tags:
- setup-all - setup-all
- import_tasks: "{{ role_path }}/tasks/server_base/setup.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/server_base/setup.yml"
when: run_setup|bool when: run_setup | bool
tags: tags:
- setup-all - setup-all
# This needs to always run, because it populates `matrix_user_uid` and `matrix_user_gid`, # This needs to always run, because it populates `matrix_user_uid` and `matrix_user_gid`,
# which are required by many other roles. # which are required by many other roles.
- import_tasks: "{{ role_path }}/tasks/setup_matrix_user.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_matrix_user.yml"
when: run_setup|bool when: run_setup | bool
tags: tags:
- always - always
- setup-system-user - setup-system-user
- import_tasks: "{{ role_path }}/tasks/setup_matrix_base.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_matrix_base.yml"
when: run_setup|bool when: run_setup | bool
tags: tags:
- setup-all - setup-all
- import_tasks: "{{ role_path }}/tasks/setup_well_known.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_well_known.yml"
when: run_setup|bool when: run_setup | bool
tags: tags:
- setup-all - setup-all
- setup-ma1sd - setup-ma1sd

View File

@ -1,27 +1,27 @@
--- ---
- name: Fail if invalid homeserver implementation - name: Fail if invalid homeserver implementation
fail: ansible.builtin.fail:
msg: "You need to set a valid homeserver implementation in `matrix_homeserver_implementation`" msg: "You need to set a valid homeserver implementation in `matrix_homeserver_implementation`"
when: "matrix_homeserver_implementation not in ['synapse', 'dendrite']" when: "matrix_homeserver_implementation not in ['synapse', 'dendrite']"
# We generally support Ansible 2.7.1 and above. # We generally support Ansible 2.7.1 and above.
- name: Fail if running on Ansible < 2.7.1 - 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" 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: 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)" - "(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 # Though we do not support Ansible 2.9.6 which is buggy
- name: Fail if running on Ansible 2.9.6 on Ubuntu - 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" 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: when:
- ansible_distribution == 'Ubuntu' - ansible_distribution == 'Ubuntu'
- "ansible_version.major == 2 and ansible_version.minor == 9 and ansible_version.revision == 6" - "ansible_version.major == 2 and ansible_version.minor == 9 and ansible_version.revision == 6"
- name: (Deprecation) Catch and report renamed settings - name: (Deprecation) Catch and report renamed settings
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). 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. # 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 - name: Fail if matrix_homeserver_generic_secret_key is undefined
fail: ansible.builtin.fail:
msg: | msg: |
The `matrix_homeserver_generic_secret_key` variable must be defined and have a non-null and non-empty value. The `matrix_homeserver_generic_secret_key` variable must be defined and have a non-null and non-empty value.
@ -47,41 +47,41 @@
when: "matrix_homeserver_generic_secret_key is none or matrix_homeserver_generic_secret_key == ''" when: "matrix_homeserver_generic_secret_key is none or matrix_homeserver_generic_secret_key == ''"
- name: Fail if required variables are undefined - 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" msg: "The `{{ item.var }}` variable must be defined and have a non-null and non-empty value"
with_items: with_items:
- {'var': matrix_domain, 'value': "{{ matrix_domain|default('') }}"} - {'var': matrix_domain, 'value': "{{ matrix_domain | default('') }}"}
- {'var': matrix_server_fqn_matrix, 'value': "{{ matrix_server_fqn_matrix|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_server_fqn_element, 'value': "{{ matrix_server_fqn_element | default('') }}"}
- {'var': matrix_homeserver_container_url, 'value': "{{ matrix_homeserver_container_url|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_homeserver_container_federation_url, 'value': "{{ matrix_homeserver_container_federation_url | default('') }}"}
when: "item.value is none or item.value == ''" when: "item.value is none or item.value == ''"
- name: Fail if uppercase domain used - 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!" msg: "Detected that you're using an uppercase domain name - `{{ item }}`. This will cause trouble. Please use all-lowercase!"
with_items: with_items:
- "{{ matrix_domain }}" - "{{ matrix_domain }}"
- "{{ matrix_server_fqn_matrix }}" - "{{ matrix_server_fqn_matrix }}"
- "{{ matrix_server_fqn_element }}" - "{{ matrix_server_fqn_element }}"
when: "item != item|lower" when: "item != item | lower"
- name: Fail if using python2 on Archlinux - 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." msg: "Detected that you're using python2 when installing onto Archlinux. Archlinux by default only supports python3."
when: when:
- ansible_distribution == 'Archlinux' - ansible_distribution == 'Archlinux'
- ansible_python.version.major != 3 - ansible_python.version.major != 3
- name: Fail if architecture is set incorrectly - 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 }}." 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 when: (ansible_architecture == "x86_64" and matrix_architecture != "amd64") or
(ansible_architecture == "aarch64" and matrix_architecture != "arm64") or (ansible_architecture == "aarch64" and matrix_architecture != "arm64") or
(ansible_architecture.startswith("armv") and matrix_architecture != "arm32") (ansible_architecture.startswith("armv") and matrix_architecture != "arm32")
- name: Fail if encountering usage of removed role (mx-puppet-skype) - name: Fail if encountering usage of removed role (mx-puppet-skype)
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration seems to include a reference to `matrix_mx_puppet_skype_enabled`. Are you trying to install the mx-puppet-skype bridge? 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. 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.

View File

@ -1,18 +1,18 @@
--- ---
- include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml" - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat.yml"
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int < 8 when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int < 8
- include_tasks: "{{ role_path }}/tasks/server_base/setup_redhat8.yml" - 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 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" - ansible.builtin.include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml"
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int > 30 when: ansible_os_family == 'RedHat' and ansible_distribution_major_version | int > 30
- block: - block:
# ansible_lsb is only available if lsb-release is installed. # ansible_lsb is only available if lsb-release is installed.
- name: Ensure lsb-release installed - name: Ensure lsb-release installed
apt: ansible.builtin.apt:
name: name:
- lsb-release - lsb-release
state: present state: present
@ -20,27 +20,27 @@
register: lsb_release_installation_result register: lsb_release_installation_result
- name: Reread ansible_lsb facts if lsb-release got installed - 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 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') 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') and (ansible_lsb.id == 'Raspbian')
when: ansible_os_family == 'Debian' 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' when: ansible_distribution == 'Archlinux'
- name: Ensure Docker is started and autoruns - name: Ensure Docker is started and autoruns
service: ansible.builtin.service:
name: docker name: docker
state: started state: started
enabled: true enabled: true
- name: "Ensure {{ matrix_ntpd_service }} is started and autoruns" - name: "Ensure {{ matrix_ntpd_service }} is started and autoruns"
service: ansible.builtin.service:
name: "{{ matrix_ntpd_service }}" name: "{{ matrix_ntpd_service }}"
state: started state: started
enabled: true enabled: true

View File

@ -5,12 +5,12 @@
name: name:
- python-docker - python-docker
- python-dnspython - python-dnspython
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
pacman: pacman:
name: name:
- docker - docker
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure APT usage dependencies are installed - name: Ensure APT usage dependencies are installed
apt: ansible.builtin.apt:
name: name:
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
@ -10,32 +10,32 @@
update_cache: true update_cache: true
- name: Ensure Docker's APT key is trusted - name: Ensure Docker's APT key is trusted
apt_key: ansible.builtin.apt_key:
url: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg" url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present state: present
register: add_repository_key register: add_repository_key
ignore_errors: true 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 - name: Ensure Docker repository is enabled
apt_repository: ansible.builtin.apt_repository:
repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable" repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present state: present
update_cache: true 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 - name: Ensure APT packages are installed
apt: ansible.builtin.apt:
name: name:
- "{{ matrix_ntpd_package }}" - "{{ matrix_ntpd_package }}"
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
apt: ansible.builtin.apt:
name: name:
- "{{ matrix_docker_package_name }}" - "{{ matrix_docker_package_name }}"
- "python{{'3' if ansible_python.version.major == 3 else ''}}-docker" - "python{{ '3' if ansible_python.version.major == 3 else '' }}-docker"
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure Docker repository is enabled - name: Ensure Docker repository is enabled
template: ansible.builtin.template:
src: "{{ role_path }}/files/yum.repos.d/{{ item }}" src: "{{ role_path }}/files/yum.repos.d/{{ item }}"
dest: "/etc/yum.repos.d/docker-ce.repo" dest: "/etc/yum.repos.d/docker-ce.repo"
owner: "root" owner: "root"
@ -9,31 +9,31 @@
mode: 0644 mode: 0644
with_items: with_items:
- docker-ce-fedora.repo - 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 - name: Ensure Docker's RPM key is trusted
rpm_key: ansible.builtin.rpm_key:
state: present state: present
key: https://download.docker.com/linux/fedora/gpg 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 - name: Ensure yum packages are installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_ntpd_package }}" - "{{ matrix_ntpd_package }}"
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_docker_package_name }}" - "{{ matrix_docker_package_name }}"
- python3-pip - python3-pip
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool
- name: Ensure Docker-Py is installed - name: Ensure Docker-Py is installed
pip: ansible.builtin.pip:
name: docker-py name: docker-py
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure APT usage dependencies are installed - name: Ensure APT usage dependencies are installed
apt: ansible.builtin.apt:
name: name:
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
@ -10,32 +10,32 @@
update_cache: true update_cache: true
- name: Ensure Docker's APT key is trusted - name: Ensure Docker's APT key is trusted
apt_key: ansible.builtin.apt_key:
url: https://download.docker.com/linux/raspbian/gpg url: https://download.docker.com/linux/raspbian/gpg
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present state: present
register: add_repository_key register: add_repository_key
ignore_errors: true 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 - 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" repo: "deb [arch={{ matrix_debian_arch }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable"
state: present state: present
update_cache: true 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 - name: Ensure APT packages are installed
apt: ansible.builtin.apt:
name: name:
- "{{ matrix_ntpd_package }}" - "{{ matrix_ntpd_package }}"
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
apt: ansible.builtin.apt:
name: name:
- "{{ matrix_docker_package_name }}" - "{{ matrix_docker_package_name }}"
- "python{{'3' if ansible_python.version.major == 3 else ''}}-docker" - "python{{'3' if ansible_python.version.major == 3 else ''}}-docker"
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,31 +1,31 @@
--- ---
- name: Ensure Docker repository is enabled - name: Ensure Docker repository is enabled
template: ansible.builtin.template:
src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo"
dest: "/etc/yum.repos.d/docker-ce.repo" dest: "/etc/yum.repos.d/docker-ce.repo"
owner: "root" owner: "root"
group: "root" group: "root"
mode: 0644 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 - name: Ensure Docker's RPM key is trusted
rpm_key: ansible.builtin.rpm_key:
state: present state: present
key: https://download.docker.com/linux/centos/gpg 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 - name: Ensure yum packages are installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_ntpd_package }}" - "{{ matrix_ntpd_package }}"
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_docker_package_name }}" - "{{ matrix_docker_package_name }}"
- docker-python - docker-python
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,44 +1,44 @@
--- ---
- name: Ensure Docker repository is enabled - name: Ensure Docker repository is enabled
template: ansible.builtin.template:
src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo" src: "{{ role_path }}/files/yum.repos.d/docker-ce-centos.repo"
dest: "/etc/yum.repos.d/docker-ce.repo" dest: "/etc/yum.repos.d/docker-ce.repo"
owner: "root" owner: "root"
group: "root" group: "root"
mode: 0644 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 - name: Ensure Docker's RPM key is trusted
rpm_key: ansible.builtin.rpm_key:
state: present state: present
key: https://download.docker.com/linux/centos/gpg 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 - name: Ensure EPEL is installed
yum: ansible.builtin.yum:
name: name:
- epel-release - epel-release
state: latest state: present
update_cache: true update_cache: true
- name: Ensure yum packages are installed - name: Ensure yum packages are installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_ntpd_package }}" - "{{ matrix_ntpd_package }}"
state: latest state: present
update_cache: true update_cache: true
- name: Ensure Docker is installed - name: Ensure Docker is installed
yum: ansible.builtin.yum:
name: name:
- "{{ matrix_docker_package_name }}" - "{{ matrix_docker_package_name }}"
- python3-pip - python3-pip
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool
- name: Ensure Docker-Py is installed - name: Ensure Docker-Py is installed
pip: ansible.builtin.pip:
name: docker-py name: docker-py
state: latest state: present
when: matrix_docker_installation_enabled|bool when: matrix_docker_installation_enabled | bool

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure Matrix base path exists - name: Ensure Matrix base path exists
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: "{{ matrix_base_data_path_mode }}" mode: "{{ matrix_base_data_path_mode }}"
@ -11,13 +11,13 @@
- "{{ matrix_base_data_path }}" - "{{ matrix_base_data_path }}"
- name: Preserve vars.yml on the server for easily restoring if it gets lost later on - 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 }}" src: "{{ matrix_vars_yml_snapshotting_src }}"
dest: "{{ matrix_base_data_path }}/vars.yml" dest: "{{ matrix_base_data_path }}/vars.yml"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
mode: '0660' mode: '0660'
when: "matrix_vars_yml_snapshotting_enabled|bool" when: "matrix_vars_yml_snapshotting_enabled | bool"
- name: Ensure Matrix network is created in Docker - name: Ensure Matrix network is created in Docker
docker_network: docker_network:
@ -25,7 +25,7 @@
driver: bridge driver: bridge
- name: Ensure matrix-remove-all script created - name: Ensure matrix-remove-all script created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2" src: "{{ role_path }}/templates/usr-local-bin/matrix-remove-all.j2"
dest: "{{ matrix_local_bin_path }}/matrix-remove-all" dest: "{{ matrix_local_bin_path }}/matrix-remove-all"
mode: 0750 mode: 0750

View File

@ -1,18 +1,18 @@
--- ---
- name: Ensure Matrix group is created - name: Ensure Matrix group is created
group: ansible.builtin.group:
name: "{{ matrix_user_groupname }}" name: "{{ matrix_user_groupname }}"
gid: "{{ omit if matrix_user_gid is none else matrix_user_gid }}" gid: "{{ omit if matrix_user_gid is none else matrix_user_gid }}"
state: present state: present
register: matrix_group register: matrix_group
- name: Set Matrix Group GID Variable - name: Set Matrix Group GID Variable
set_fact: ansible.builtin.set_fact:
matrix_user_gid: "{{ matrix_group.gid }}" matrix_user_gid: "{{ matrix_group.gid }}"
- name: Ensure Matrix user is created - name: Ensure Matrix user is created
user: ansible.builtin.user:
name: "{{ matrix_user_username }}" name: "{{ matrix_user_username }}"
uid: "{{ omit if matrix_user_uid is none else matrix_user_uid }}" uid: "{{ omit if matrix_user_uid is none else matrix_user_uid }}"
state: present state: present
@ -23,5 +23,5 @@
register: matrix_user register: matrix_user
- name: Set Matrix Group UID Variable - name: Set Matrix Group UID Variable
set_fact: ansible.builtin.set_fact:
matrix_user_uid: "{{ matrix_user.uid }}" matrix_user_uid: "{{ matrix_user.uid }}"

View File

@ -4,7 +4,7 @@
# #
# For running with another webserver, we recommend being part of the `matrix` group. # For running with another webserver, we recommend being part of the `matrix` group.
- name: Ensure Matrix static-files path exists - name: Ensure Matrix static-files path exists
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: 0755 mode: 0755
@ -14,27 +14,27 @@
- "{{ matrix_static_files_base_path }}/.well-known/matrix" - "{{ matrix_static_files_base_path }}/.well-known/matrix"
- name: Ensure Matrix /.well-known/matrix/client file configured - name: Ensure Matrix /.well-known/matrix/client file configured
copy: ansible.builtin.copy:
content: "{{ matrix_well_known_matrix_client_configuration|to_nice_json }}" content: "{{ matrix_well_known_matrix_client_configuration | to_nice_json }}"
dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/client" dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/client"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure Matrix /.well-known/matrix/server file configured - name: Ensure Matrix /.well-known/matrix/server file configured
copy: ansible.builtin.copy:
content: "{{ matrix_well_known_matrix_server_configuration|to_nice_json }}" content: "{{ matrix_well_known_matrix_server_configuration | to_nice_json }}"
dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/server" dest: "{{ matrix_static_files_base_path }}/.well-known/matrix/server"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" 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 - name: Ensure Matrix /.well-known/matrix/server file deleted
file: ansible.builtin.file:
path: "{{ matrix_static_files_base_path }}/.well-known/matrix/server" path: "{{ matrix_static_files_base_path }}/.well-known/matrix/server"
state: absent 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 - name: Ensure Matrix /.well-known/matrix/support file configured
ansible.builtin.copy: ansible.builtin.copy:

View File

@ -1,23 +1,23 @@
--- ---
# This is for both RedHat 7 and 8 # This is for both RedHat 7 and 8
- name: Ensure fuse installed (RedHat) - name: Ensure fuse installed (RedHat)
yum: ansible.builtin.yum:
name: name:
- fuse - fuse
state: latest state: present
when: ansible_os_family == 'RedHat' when: ansible_os_family == 'RedHat'
# This is for both Debian and Raspbian # This is for both Debian and Raspbian
- name: Ensure fuse installed (Debian/Raspbian) - name: Ensure fuse installed (Debian/Raspbian)
apt: ansible.builtin.apt:
name: name:
- fuse - fuse
state: latest state: present
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: Ensure fuse installed (Archlinux) - name: Ensure fuse installed (Archlinux)
pacman: pacman:
name: name:
- fuse3 - fuse3
state: latest state: present
when: ansible_distribution == 'Archlinux' when: ansible_distribution == 'Archlinux'

View File

@ -1,23 +1,23 @@
--- ---
# This is for both RedHat 7 and 8 # This is for both RedHat 7 and 8
- name: Ensure openssl installed (RedHat) - name: Ensure openssl installed (RedHat)
yum: ansible.builtin.yum:
name: name:
- openssl - openssl
state: latest state: present
when: ansible_os_family == 'RedHat' when: ansible_os_family == 'RedHat'
# This is for both Debian and Raspbian # This is for both Debian and Raspbian
- name: Ensure openssl installed (Debian/Raspbian) - name: Ensure openssl installed (Debian/Raspbian)
apt: ansible.builtin.apt:
name: name:
- openssl - openssl
state: latest state: present
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: Ensure openssl installed (Archlinux) - name: Ensure openssl installed (Archlinux)
pacman: pacman:
name: name:
- openssl - openssl
state: latest state: present
when: ansible_distribution == 'Archlinux' when: ansible_distribution == 'Archlinux'

View File

@ -6,6 +6,7 @@ matrix_bot_buscarron_enabled: true
matrix_bot_buscarron_container_image_self_build: false 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: "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_docker_src_files_path: "{{ matrix_base_data_path }}/buscarron/docker-src"
matrix_bot_buscarron_version: v1.2.0 matrix_bot_buscarron_version: v1.2.0

View File

@ -1,5 +1,5 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-buscarron.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-buscarron.service'] }}"
when: matrix_bot_buscarron_enabled|bool when: matrix_bot_buscarron_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_buscarron_enabled|bool" when: "run_setup | bool and matrix_bot_buscarron_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-buscarron - setup-bot-buscarron
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_buscarron_enabled|bool" when: "run_setup | bool and matrix_bot_buscarron_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-buscarron - setup-bot-buscarron
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_buscarron_enabled|bool" when: "run_setup | bool and not matrix_bot_buscarron_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-buscarron - setup-bot-buscarron

View File

@ -1,32 +1,34 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_bot_buscarron_requires_restart: false matrix_bot_buscarron_requires_restart: false
- block: - block:
- name: Check if an SQLite database already exists - name: Check if an SQLite database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_bot_buscarron_sqlite_database_path_local }}" path: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
register: matrix_bot_buscarron_sqlite_database_path_local_stat_result register: matrix_bot_buscarron_sqlite_database_path_local_stat_result
- block: - block:
- set_fact: - ansible.builtin.set_fact:
matrix_postgres_db_migration_request: matrix_postgres_db_migration_request:
src: "{{ matrix_bot_buscarron_sqlite_database_path_local }}" src: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
dst: "{{ matrix_bot_buscarron_database_connection_string }}" dst: "{{ matrix_bot_buscarron_database_connection_string }}"
caller: "{{ role_path|basename }}" caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_bot_buscarron_database_engine' engine_variable_name: 'matrix_bot_buscarron_database_engine'
engine_old: 'sqlite' engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-bot-buscarron.service'] systemd_services_to_stop: ['matrix-bot-buscarron.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_buscarron_requires_restart: true matrix_bot_buscarron_requires_restart: true
when: "matrix_bot_buscarron_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_bot_buscarron_sqlite_database_path_local_stat_result.stat.exists | bool"
when: "matrix_bot_buscarron_database_engine == 'postgres'" when: "matrix_bot_buscarron_database_engine == 'postgres'"
- name: Ensure buscarron paths exist - name: Ensure buscarron paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -37,10 +39,10 @@
- {path: "{{ matrix_bot_buscarron_data_path }}", when: true} - {path: "{{ matrix_bot_buscarron_data_path }}", when: true}
- {path: "{{ matrix_bot_buscarron_data_store_path }}", when: true} - {path: "{{ matrix_bot_buscarron_data_store_path }}", when: true}
- {path: "{{ matrix_bot_buscarron_docker_src_files_path }}", when: true} - {path: "{{ matrix_bot_buscarron_docker_src_files_path }}", when: true}
when: "item.when|bool" when: "item.when | bool"
- name: Ensure buscarron environment variables file created - name: Ensure buscarron environment variables file created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2" src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_bot_buscarron_config_path }}/env" dest: "{{ matrix_bot_buscarron_config_path }}/env"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -53,21 +55,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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" when: "not matrix_bot_buscarron_container_image_self_build | bool"
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure buscarron repository is present on self-build - name: Ensure buscarron repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_bot_buscarron_docker_repo }}" repo: "{{ matrix_bot_buscarron_docker_repo }}"
version: "{{ matrix_bot_buscarron_docker_repo_version }}"
dest: "{{ matrix_bot_buscarron_docker_src_files_path }}" dest: "{{ matrix_bot_buscarron_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_bot_buscarron_git_pull_results register: matrix_bot_buscarron_git_pull_results
when: "matrix_bot_buscarron_container_image_self_build|bool" when: "matrix_bot_buscarron_container_image_self_build | bool"
- name: Ensure buscarron image is built - name: Ensure buscarron image is built
docker_image: docker_image:
@ -79,22 +82,22 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_bot_buscarron_docker_src_files_path }}" path: "{{ matrix_bot_buscarron_docker_src_files_path }}"
pull: true pull: true
when: "matrix_bot_buscarron_container_image_self_build|bool" when: "matrix_bot_buscarron_container_image_self_build | bool"
- name: Ensure matrix-bot-buscarron.service installed - name: Ensure matrix-bot-buscarron.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2" src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service" dest: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
mode: 0644 mode: 0644
register: matrix_bot_buscarron_systemd_service_result register: matrix_bot_buscarron_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-buscarron.service installation - name: Ensure systemd reloaded after matrix-bot-buscarron.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_bot_buscarron_systemd_service_result.changed|bool" when: "matrix_bot_buscarron_systemd_service_result.changed | bool"
- name: Ensure matrix-bot-buscarron.service restarted, if necessary - name: Ensure matrix-bot-buscarron.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-buscarron.service" name: "matrix-bot-buscarron.service"
state: restarted state: restarted
when: "matrix_bot_buscarron_requires_restart|bool" when: "matrix_bot_buscarron_requires_restart | bool"

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-buscarron service - name: Check existence of matrix-buscarron service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service" path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
register: matrix_bot_buscarron_service_stat register: matrix_bot_buscarron_service_stat
- name: Ensure matrix-buscarron is stopped - name: Ensure matrix-buscarron is stopped
service: ansible.builtin.service:
name: matrix-bot-buscarron name: matrix-bot-buscarron
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result register: stopping_result
when: "matrix_bot_buscarron_service_stat.stat.exists|bool" when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
- name: Ensure matrix-bot-buscarron.service doesn't exist - name: Ensure matrix-bot-buscarron.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service" path: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
state: absent state: absent
when: "matrix_bot_buscarron_service_stat.stat.exists|bool" when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
- name: Ensure systemd reloaded after matrix-bot-buscarron.service removal - name: Ensure systemd reloaded after matrix-bot-buscarron.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_bot_buscarron_service_stat.stat.exists|bool" when: "matrix_bot_buscarron_service_stat.stat.exists | bool"
- name: Ensure Matrix buscarron paths don't exist - name: Ensure Matrix buscarron paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_buscarron_base_path }}" path: "{{ matrix_bot_buscarron_base_path }}"
state: absent state: absent

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"

View File

@ -224,8 +224,8 @@ matrix_bot_go_neb_configuration_extension_yaml: |
# If you need something more special, you can take full control by # If you need something more special, you can take full control by
# completely redefining `matrix_bot_go_neb_configuration_yaml`. # 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). # 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`. # 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) }}"

View File

@ -1,5 +1,5 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-go-neb.service'] }}" 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

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_go_neb_enabled|bool" when: "run_setup | bool and matrix_bot_go_neb_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-go-neb - setup-bot-go-neb
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_go_neb_enabled|bool" when: "run_setup | bool and matrix_bot_go_neb_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-go-neb - setup-bot-go-neb
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_go_neb_enabled|bool" when: "run_setup | bool and not matrix_bot_go_neb_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-go-neb - setup-bot-go-neb

View File

@ -1,10 +1,10 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_bot_go_neb_requires_restart: false matrix_bot_go_neb_requires_restart: false
- name: Ensure go-neb paths exist - name: Ensure go-neb paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -14,7 +14,7 @@
- {path: "{{ matrix_bot_go_neb_config_path }}", when: true} - {path: "{{ matrix_bot_go_neb_config_path }}", when: true}
- {path: "{{ matrix_bot_go_neb_data_path }}", when: true} - {path: "{{ matrix_bot_go_neb_data_path }}", when: true}
- {path: "{{ matrix_bot_go_neb_data_store_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 - name: Ensure go-neb image is pulled
docker_image: docker_image:
@ -28,27 +28,27 @@
until: result is not failed until: result is not failed
- name: Ensure go-neb config installed - name: Ensure go-neb config installed
copy: ansible.builtin.copy:
content: "{{ matrix_bot_go_neb_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_bot_go_neb_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_bot_go_neb_config_path }}/config.yaml" dest: "{{ matrix_bot_go_neb_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-bot-go-neb.service installed - name: Ensure matrix-bot-go-neb.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-go-neb.service.j2" src: "{{ role_path }}/templates/systemd/matrix-bot-go-neb.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service" dest: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
mode: 0644 mode: 0644
register: matrix_bot_go_neb_systemd_service_result register: matrix_bot_go_neb_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-go-neb.service installation - name: Ensure systemd reloaded after matrix-bot-go-neb.service installation
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-bot-go-neb.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-go-neb.service" name: "matrix-bot-go-neb.service"
state: restarted state: restarted
when: "matrix_bot_go_neb_requires_restart|bool" when: "matrix_bot_go_neb_requires_restart | bool"

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-go-neb service - name: Check existence of matrix-go-neb service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service" path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
register: matrix_bot_go_neb_service_stat register: matrix_bot_go_neb_service_stat
- name: Ensure matrix-go-neb is stopped - name: Ensure matrix-go-neb is stopped
service: ansible.builtin.service:
name: matrix-bot-go-neb name: matrix-bot-go-neb
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result 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 - name: Ensure matrix-bot-go-neb.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service" path: "{{ matrix_systemd_path }}/matrix-bot-go-neb.service"
state: absent 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 - name: Ensure systemd reloaded after matrix-bot-go-neb.service removal
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure Matrix go-neb paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_go_neb_base_path }}" path: "{{ matrix_bot_go_neb_base_path }}"
state: absent state: absent

View File

@ -1,13 +1,13 @@
--- ---
- name: Fail if there's not at least 1 client - name: Fail if there's not at least 1 client
fail: ansible.builtin.fail:
msg: >- msg: >-
You need at least 1 client in the matrix_bot_go_neb_clients block. 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 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 - name: Fail if there's not at least 1 service
fail: ansible.builtin.fail:
msg: >- msg: >-
You need at least 1 service in the matrix_bot_go_neb_services block. 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 when: matrix_bot_go_neb_services is not defined or matrix_bot_go_neb_services[0] is not defined

View File

@ -6,6 +6,7 @@ matrix_bot_honoroit_enabled: true
matrix_bot_honoroit_container_image_self_build: false 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: "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_docker_src_files_path: "{{ matrix_base_data_path }}/honoroit/docker-src"
matrix_bot_honoroit_version: v0.9.9 matrix_bot_honoroit_version: v0.9.9

View File

@ -1,5 +1,5 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-honoroit.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-honoroit.service'] }}"
when: matrix_bot_honoroit_enabled|bool when: matrix_bot_honoroit_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_honoroit_enabled|bool" when: "run_setup | bool and matrix_bot_honoroit_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-honoroit - setup-bot-honoroit
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_honoroit_enabled|bool" when: "run_setup | bool and matrix_bot_honoroit_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-honoroit - setup-bot-honoroit
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_honoroit_enabled|bool" when: "run_setup | bool and not matrix_bot_honoroit_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-honoroit - setup-bot-honoroit

View File

@ -1,32 +1,34 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_bot_honoroit_requires_restart: false matrix_bot_honoroit_requires_restart: false
- block: - block:
- name: Check if an SQLite database already exists - name: Check if an SQLite database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}" path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
register: matrix_bot_honoroit_sqlite_database_path_local_stat_result register: matrix_bot_honoroit_sqlite_database_path_local_stat_result
- block: - block:
- set_fact: - ansible.builtin.set_fact:
matrix_postgres_db_migration_request: matrix_postgres_db_migration_request:
src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}" src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
dst: "{{ matrix_bot_honoroit_database_connection_string }}" dst: "{{ matrix_bot_honoroit_database_connection_string }}"
caller: "{{ role_path|basename }}" caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_bot_honoroit_database_engine' engine_variable_name: 'matrix_bot_honoroit_database_engine'
engine_old: 'sqlite' engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-bot-honoroit.service'] 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 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'" when: "matrix_bot_honoroit_database_engine == 'postgres'"
- name: Ensure honoroit paths exist - name: Ensure honoroit paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -37,10 +39,10 @@
- {path: "{{ matrix_bot_honoroit_data_path }}", when: true} - {path: "{{ matrix_bot_honoroit_data_path }}", when: true}
- {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true} - {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true}
- {path: "{{ matrix_bot_honoroit_docker_src_files_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 - name: Ensure honoroit environment variables file created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2" src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_bot_honoroit_config_path }}/env" dest: "{{ matrix_bot_honoroit_config_path }}/env"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -53,21 +55,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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 register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure honoroit repository is present on self-build - name: Ensure honoroit repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_bot_honoroit_docker_repo }}" repo: "{{ matrix_bot_honoroit_docker_repo }}"
version: "{{ matrix_bot_honoroit_docker_repo_version }}"
dest: "{{ matrix_bot_honoroit_docker_src_files_path }}" dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_bot_honoroit_git_pull_results 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 - name: Ensure honoroit image is built
docker_image: docker_image:
@ -79,22 +82,22 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_bot_honoroit_docker_src_files_path }}" path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
pull: true 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 - name: Ensure matrix-bot-honoroit.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2" src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service" dest: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
mode: 0644 mode: 0644
register: matrix_bot_honoroit_systemd_service_result register: matrix_bot_honoroit_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-honoroit.service installation - name: Ensure systemd reloaded after matrix-bot-honoroit.service installation
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-bot-honoroit.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-honoroit.service" name: "matrix-bot-honoroit.service"
state: restarted state: restarted
when: "matrix_bot_honoroit_requires_restart|bool" when: "matrix_bot_honoroit_requires_restart | bool"

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-honoroit service - name: Check existence of matrix-honoroit service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service" path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
register: matrix_bot_honoroit_service_stat register: matrix_bot_honoroit_service_stat
- name: Ensure matrix-honoroit is stopped - name: Ensure matrix-honoroit is stopped
service: ansible.builtin.service:
name: matrix-bot-honoroit name: matrix-bot-honoroit
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result 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 - name: Ensure matrix-bot-honoroit.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service" path: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
state: absent 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 - name: Ensure systemd reloaded after matrix-bot-honoroit.service removal
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure Matrix honoroit paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_honoroit_base_path }}" path: "{{ matrix_bot_honoroit_base_path }}"
state: absent state: absent

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"

View File

@ -5,6 +5,7 @@
matrix_bot_matrix_registration_bot_enabled: true matrix_bot_matrix_registration_bot_enabled: true
matrix_bot_matrix_registration_bot_container_image_self_build: false 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: "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_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_version: latest

View File

@ -1,5 +1,5 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-registration-bot.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-registration-bot.service'] }}"
when: matrix_bot_matrix_registration_bot_enabled|bool when: matrix_bot_matrix_registration_bot_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_matrix_registration_bot_enabled|bool" when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-registration-bot - setup-bot-matrix-registration-bot
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_matrix_registration_bot_enabled|bool" when: "run_setup | bool and matrix_bot_matrix_registration_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-registration-bot - setup-bot-matrix-registration-bot
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_matrix_registration_bot_enabled|bool" when: "run_setup | bool and not matrix_bot_matrix_registration_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-registration-bot - setup-bot-matrix-registration-bot

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure matrix-registration-bot paths exist - name: Ensure matrix-registration-bot paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -11,10 +11,10 @@
- {path: "{{ matrix_bot_matrix_registration_bot_config_path }}", when: true} - {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_data_path }}", when: true}
- {path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}", when: true} - {path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}", when: true}
when: "item.when|bool" when: "item.when | bool"
- name: Ensure matrix-registration-bot configuration file created - name: Ensure matrix-registration-bot configuration file created
template: ansible.builtin.template:
src: "{{ role_path }}/templates/config/config.yml.j2" src: "{{ role_path }}/templates/config/config.yml.j2"
dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yml" dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yml"
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -27,21 +27,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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" when: "not matrix_bot_matrix_registration_bot_container_image_self_build | bool"
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure matrix-registration-bot repository is present on self-build - name: Ensure matrix-registration-bot repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_bot_matrix_registration_bot_docker_repo }}" 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 }}" dest: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_bot_matrix_registration_bot_git_pull_results register: matrix_bot_matrix_registration_bot_git_pull_results
when: "matrix_bot_matrix_registration_bot_container_image_self_build|bool" when: "matrix_bot_matrix_registration_bot_container_image_self_build | bool"
- name: Ensure matrix-registration-bot image is built - name: Ensure matrix-registration-bot image is built
docker_image: docker_image:
@ -53,21 +54,21 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}" path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
pull: true pull: true
when: "matrix_bot_matrix_registration_bot_container_image_self_build|bool" when: "matrix_bot_matrix_registration_bot_container_image_self_build | bool"
- name: Ensure matrix-bot-matrix-registration-bot.service installed - name: Ensure matrix-bot-matrix-registration-bot.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2" src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service" dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
mode: 0644 mode: 0644
register: matrix_bot_matrix_registration_bot_systemd_service_result register: matrix_bot_matrix_registration_bot_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service installation - name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_bot_matrix_registration_bot_systemd_service_result.changed|bool" when: "matrix_bot_matrix_registration_bot_systemd_service_result.changed | bool"
- name: Ensure matrix-bot-matrix-registration-bot.service restarted, if necessary - name: Ensure matrix-bot-matrix-registration-bot.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-matrix-registration-bot.service" name: "matrix-bot-matrix-registration-bot.service"
state: restarted state: restarted

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-matrix-registration-bot service - name: Check existence of matrix-matrix-registration-bot service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service" path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
register: matrix_bot_matrix_registration_bot_service_stat register: matrix_bot_matrix_registration_bot_service_stat
- name: Ensure matrix-matrix-registration-bot is stopped - name: Ensure matrix-matrix-registration-bot is stopped
service: ansible.builtin.service:
name: matrix-bot-matrix-registration-bot name: matrix-bot-matrix-registration-bot
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result register: stopping_result
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
- name: Ensure matrix-bot-matrix-registration-bot.service doesn't exist - name: Ensure matrix-bot-matrix-registration-bot.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service" path: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
state: absent state: absent
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
- name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service removal - name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists|bool" when: "matrix_bot_matrix_registration_bot_service_stat.stat.exists | bool"
- name: Ensure Matrix matrix-registration-bot paths don't exist - name: Ensure Matrix matrix-registration-bot paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_matrix_registration_bot_base_path }}" path: "{{ matrix_bot_matrix_registration_bot_base_path }}"
state: absent state: absent

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"

View File

@ -6,6 +6,7 @@ matrix_bot_matrix_reminder_bot_enabled: true
matrix_bot_matrix_reminder_bot_container_image_self_build: false 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: "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_docker_src_files_path: "{{ matrix_base_data_path }}/matrix-reminder-bot/docker-src"
matrix_bot_matrix_reminder_bot_version: release-v0.2.1 matrix_bot_matrix_reminder_bot_version: release-v0.2.1
@ -93,8 +94,8 @@ matrix_bot_matrix_reminder_bot_configuration_extension_yaml: |
# matrix: # matrix:
# device_name: My-Reminder-Bot # 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). # 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`. # 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) }}"

View File

@ -1,5 +1,5 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-matrix-reminder-bot.service'] }}" 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

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_matrix_reminder_bot_enabled|bool" when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-reminder-bot - setup-bot-matrix-reminder-bot
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_matrix_reminder_bot_enabled|bool" when: "run_setup | bool and matrix_bot_matrix_reminder_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-reminder-bot - setup-bot-matrix-reminder-bot
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_matrix_reminder_bot_enabled|bool" when: "run_setup | bool and not matrix_bot_matrix_reminder_bot_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-matrix-reminder-bot - setup-bot-matrix-reminder-bot

View File

@ -1,33 +1,35 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_bot_matrix_reminder_bot_requires_restart: false matrix_bot_matrix_reminder_bot_requires_restart: false
- block: - block:
- name: Check if an SQLite database already exists - name: Check if an SQLite database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}" path: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}"
register: matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result register: matrix_bot_matrix_reminder_bot_sqlite_database_path_local_stat_result
- block: - block:
- set_fact: - ansible.builtin.set_fact:
matrix_postgres_db_migration_request: matrix_postgres_db_migration_request:
src: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}" src: "{{ matrix_bot_matrix_reminder_bot_sqlite_database_path_local }}"
dst: "{{ matrix_bot_matrix_reminder_bot_database_connection_string }}" 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_variable_name: 'matrix_bot_matrix_reminder_bot_database_engine'
engine_old: 'sqlite' engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-bot-matrix-reminder-bot.service'] 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 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'" when: "matrix_bot_matrix_reminder_bot_database_engine == 'postgres'"
- name: Ensure matrix-reminder-bot paths exist - name: Ensure matrix-reminder-bot paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -38,7 +40,7 @@
- {path: "{{ matrix_bot_matrix_reminder_bot_data_path }}", when: true} - {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_data_store_path }}", when: true}
- {path: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_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 - name: Ensure matrix-reminder-bot image is pulled
docker_image: docker_image:
@ -46,21 +48,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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 register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure matrix-reminder-bot repository is present on self-build - name: Ensure matrix-reminder-bot repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_bot_matrix_reminder_bot_docker_repo }}" 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 }}" dest: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_bot_matrix_reminder_bot_git_pull_results 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 - name: Ensure matrix-reminder-bot image is built
docker_image: docker_image:
@ -72,30 +75,30 @@
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
path: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}" path: "{{ matrix_bot_matrix_reminder_bot_docker_src_files_path }}"
pull: true 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 - name: Ensure matrix-reminder-bot config installed
copy: ansible.builtin.copy:
content: "{{ matrix_bot_matrix_reminder_bot_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_bot_matrix_reminder_bot_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_bot_matrix_reminder_bot_config_path }}/config.yaml" dest: "{{ matrix_bot_matrix_reminder_bot_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-bot-matrix-reminder-bot.service installed - 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" src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-reminder-bot.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service" dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
mode: 0644 mode: 0644
register: matrix_bot_matrix_reminder_bot_systemd_service_result register: matrix_bot_matrix_reminder_bot_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service installation - name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service installation
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-bot-matrix-reminder-bot.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-matrix-reminder-bot.service" name: "matrix-bot-matrix-reminder-bot.service"
state: restarted state: restarted
when: "matrix_bot_matrix_reminder_bot_requires_restart|bool" when: "matrix_bot_matrix_reminder_bot_requires_restart | bool"

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-matrix-reminder-bot service - name: Check existence of matrix-matrix-reminder-bot service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service" path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
register: matrix_bot_matrix_reminder_bot_service_stat register: matrix_bot_matrix_reminder_bot_service_stat
- name: Ensure matrix-matrix-reminder-bot is stopped - name: Ensure matrix-matrix-reminder-bot is stopped
service: ansible.builtin.service:
name: matrix-bot-matrix-reminder-bot name: matrix-bot-matrix-reminder-bot
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result 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 - 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" path: "{{ matrix_systemd_path }}/matrix-bot-matrix-reminder-bot.service"
state: absent 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 - name: Ensure systemd reloaded after matrix-bot-matrix-reminder-bot.service removal
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure Matrix matrix-reminder-bot paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_matrix_reminder_bot_base_path }}" path: "{{ matrix_bot_matrix_reminder_bot_base_path }}"
state: absent state: absent

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
@ -10,7 +10,7 @@
- "matrix_bot_matrix_reminder_bot_reminders_timezone" - "matrix_bot_matrix_reminder_bot_reminders_timezone"
- name: (Deprecation) Catch and report renamed settings - name: (Deprecation) Catch and report renamed settings
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).

View File

@ -52,8 +52,8 @@ matrix_bot_mjolnir_configuration_extension_yaml: |
# If you need something more special, you can take full control by # If you need something more special, you can take full control by
# completely redefining `matrix_bot_mjolnir_configuration_yaml`. # 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). # 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`. # 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) }}"

View File

@ -2,10 +2,10 @@
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
- name: Fail if trying to self-build on Ansible < 2.8 - 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" 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" 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'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-bot-mjolnir.service'] }}"
when: matrix_bot_mjolnir_enabled|bool when: matrix_bot_mjolnir_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_bot_mjolnir_enabled|bool" when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-mjolnir - setup-bot-mjolnir
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_bot_mjolnir_enabled|bool" when: "run_setup | bool and matrix_bot_mjolnir_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-mjolnir - setup-bot-mjolnir
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_bot_mjolnir_enabled|bool" when: "run_setup | bool and not matrix_bot_mjolnir_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-bot-mjolnir - setup-bot-mjolnir

View File

@ -1,10 +1,10 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_bot_mjolnir_requires_restart: false matrix_bot_mjolnir_requires_restart: false
- name: Ensure matrix-bot-mjolnir paths exist - name: Ensure matrix-bot-mjolnir paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -15,7 +15,7 @@
- {path: "{{ matrix_bot_mjolnir_config_path }}", when: true} - {path: "{{ matrix_bot_mjolnir_config_path }}", when: true}
- {path: "{{ matrix_bot_mjolnir_data_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 }}"} - {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 - name: Ensure mjolnir Docker image is pulled
docker_image: docker_image:
@ -23,14 +23,14 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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_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 }}" 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 register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure mjolnir repository is present on self-build - name: Ensure mjolnir repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_bot_mjolnir_container_image_self_build_repo }}" repo: "{{ matrix_bot_mjolnir_container_image_self_build_repo }}"
dest: "{{ matrix_bot_mjolnir_docker_src_files_path }}" dest: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
version: "{{ matrix_bot_mjolnir_docker_image.split(':')[1] }}" version: "{{ matrix_bot_mjolnir_docker_image.split(':')[1] }}"
@ -38,7 +38,7 @@
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_bot_mjolnir_git_pull_results 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 - name: Ensure mjolnir Docker image is built
docker_image: docker_image:
@ -49,30 +49,30 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_bot_mjolnir_docker_src_files_path }}" path: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
pull: true 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 - name: Ensure matrix-bot-mjolnir config installed
copy: ansible.builtin.copy:
content: "{{ matrix_bot_mjolnir_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_bot_mjolnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_bot_mjolnir_config_path }}/production.yaml" dest: "{{ matrix_bot_mjolnir_config_path }}/production.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-bot-mjolnir.service installed - name: Ensure matrix-bot-mjolnir.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-mjolnir.service.j2" src: "{{ role_path }}/templates/systemd/matrix-bot-mjolnir.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service" dest: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
mode: 0644 mode: 0644
register: matrix_bot_mjolnir_systemd_service_result register: matrix_bot_mjolnir_systemd_service_result
- name: Ensure systemd reloaded after matrix-bot-mjolnir.service installation - name: Ensure systemd reloaded after matrix-bot-mjolnir.service installation
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-bot-mjolnir.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-bot-mjolnir.service" name: "matrix-bot-mjolnir.service"
state: restarted state: restarted
when: "matrix_bot_mjolnir_requires_restart|bool" when: "matrix_bot_mjolnir_requires_restart | bool"

View File

@ -1,32 +1,32 @@
--- ---
- name: Check existence of matrix-bot-mjolnir service - name: Check existence of matrix-bot-mjolnir service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service" path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
register: matrix_bot_mjolnir_service_stat register: matrix_bot_mjolnir_service_stat
- name: Ensure matrix-bot-mjolnir is stopped - name: Ensure matrix-bot-mjolnir is stopped
service: ansible.builtin.service:
name: matrix-bot-mjolnir name: matrix-bot-mjolnir
state: stopped state: stopped
enabled: false enabled: false
daemon_reload: true daemon_reload: true
register: stopping_result 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 - name: Ensure matrix-bot-mjolnir.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service" path: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
state: absent 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 - name: Ensure systemd reloaded after matrix-bot-mjolnir.service removal
service: ansible.builtin.service:
daemon_reload: true 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 - name: Ensure matrix-bot-mjolnir paths don't exist
file: ansible.builtin.file:
path: "{{ matrix_bot_mjolnir_base_path }}" path: "{{ matrix_bot_mjolnir_base_path }}"
state: absent state: absent

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required variables are undefined - name: Fail if required variables are undefined
fail: ansible.builtin.fail:
msg: "The `{{ item }}` variable must be defined and have a non-null value." msg: "The `{{ item }}` variable must be defined and have a non-null value."
with_items: with_items:
- "matrix_bot_mjolnir_access_token" - "matrix_bot_mjolnir_access_token"

View File

@ -39,10 +39,10 @@ matrix_appservice_discord_appservice_url: 'http://matrix-appservice-discord:9005
matrix_appservice_discord_bridge_domain: "{{ matrix_domain }}" matrix_appservice_discord_bridge_domain: "{{ matrix_domain }}"
# As of right now, the homeserver URL must be a public URL. See below. # 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_homeserverUrl: "{{ matrix_homeserver_url }}" # noqa var-naming
matrix_appservice_discord_bridge_disablePresence: false matrix_appservice_discord_bridge_disablePresence: false # noqa var-naming
matrix_appservice_discord_bridge_enableSelfServiceBridging: false matrix_appservice_discord_bridge_enableSelfServiceBridging: false # noqa var-naming
matrix_appservice_discord_bridge_disablePortalBridging: false matrix_appservice_discord_bridge_disablePortalBridging: false # noqa var-naming
# Database-related configuration fields. # 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. # 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. # 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_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". # 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` # 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 # 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') }}" 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 # If you need something more special, you can take full control by
# completely redefining `matrix_appservice_discord_configuration_yaml`. # 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: | matrix_appservice_discord_registration_yaml: |
#jinja2: lstrip_blocks: "True" #jinja2: lstrip_blocks: "True"
@ -99,14 +99,14 @@ matrix_appservice_discord_registration_yaml: |
namespaces: namespaces:
users: users:
- exclusive: true - exclusive: true
regex: '@_discord_.*:{{ matrix_appservice_discord_homeserver_domain|regex_escape }}' regex: '@_discord_.*:{{ matrix_appservice_discord_homeserver_domain | regex_escape }}'
aliases: aliases:
- exclusive: true - 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 }} url: {{ matrix_appservice_discord_appservice_url }}
sender_localpart: _discord_bot sender_localpart: _discord_bot
rate_limited: false rate_limited: false
protocols: protocols:
- discord - discord
matrix_appservice_discord_registration: "{{ matrix_appservice_discord_registration_yaml|from_yaml }}" matrix_appservice_discord_registration: "{{ matrix_appservice_discord_registration_yaml | from_yaml }}"

View File

@ -2,28 +2,28 @@
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-discord role needs to execute before the matrix-synapse role. 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'] }}" 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. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_appservice_discord_config_path }}/registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro"] ["--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: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-appservice-discord-registration.yaml"] ["/matrix-appservice-discord-registration.yaml"]
}} }}
when: matrix_appservice_discord_enabled|bool when: matrix_appservice_discord_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_appservice_discord_enabled|bool" when: "run_setup | bool and matrix_appservice_discord_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-discord - setup-appservice-discord
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_appservice_discord_enabled|bool" when: "run_setup | bool and matrix_appservice_discord_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-discord - setup-appservice-discord
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_appservice_discord_enabled|bool" when: "run_setup | bool and not matrix_appservice_discord_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-discord - setup-appservice-discord

View File

@ -1,29 +1,31 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_appservice_discord_requires_restart: false matrix_appservice_discord_requires_restart: false
- block: - block:
- name: Check if an SQLite database already exists - name: Check if an SQLite database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_discord_sqlite_database_path_local }}" path: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
register: matrix_appservice_discord_sqlite_database_path_local_stat_result register: matrix_appservice_discord_sqlite_database_path_local_stat_result
- block: - block:
- set_fact: - ansible.builtin.set_fact:
matrix_postgres_db_migration_request: matrix_postgres_db_migration_request:
src: "{{ matrix_appservice_discord_sqlite_database_path_local }}" src: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
dst: "{{ matrix_appservice_discord_database_connString }}" dst: "{{ matrix_appservice_discord_database_connString }}"
caller: "{{ role_path|basename }}" caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_appservice_discord_database_engine' engine_variable_name: 'matrix_appservice_discord_database_engine'
engine_old: 'sqlite' engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-appservice-discord.service'] 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 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'" when: "matrix_appservice_discord_database_engine == 'postgres'"
- name: Ensure Appservice Discord image is pulled - name: Ensure Appservice Discord image is pulled
@ -38,7 +40,7 @@
until: result is not failed until: result is not failed
- name: Ensure AppService Discord paths exist - name: Ensure AppService Discord paths exist
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -50,12 +52,12 @@
- "{{ matrix_appservice_discord_data_path }}" - "{{ matrix_appservice_discord_data_path }}"
- name: Check if an old database file already exists - name: Check if an old database file already exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_discord_base_path }}/discord.db" path: "{{ matrix_appservice_discord_base_path }}/discord.db"
register: matrix_appservice_discord_stat_db register: matrix_appservice_discord_stat_db
- name: (Data relocation) Ensure matrix-appservice-discord.service is stopped - name: (Data relocation) Ensure matrix-appservice-discord.service is stopped
service: ansible.builtin.service:
name: matrix-appservice-discord name: matrix-appservice-discord
state: stopped state: stopped
enabled: false enabled: false
@ -64,7 +66,7 @@
when: "matrix_appservice_discord_stat_db.stat.exists" when: "matrix_appservice_discord_stat_db.stat.exists"
- name: (Data relocation) Move AppService Discord discord.db file to ./data directory - 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: with_items:
- discord.db - discord.db
- user-store.db - user-store.db
@ -72,16 +74,16 @@
when: "matrix_appservice_discord_stat_db.stat.exists" when: "matrix_appservice_discord_stat_db.stat.exists"
- name: Ensure AppService Discord config.yaml installed - name: Ensure AppService Discord config.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_discord_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_discord_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_discord_config_path }}/config.yaml" dest: "{{ matrix_appservice_discord_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure AppService Discord registration.yaml installed - name: Ensure AppService Discord registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_discord_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_discord_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml" dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -90,7 +92,7 @@
# If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated. # If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated.
# We intentionally suppress Ansible changes. # We intentionally suppress Ansible changes.
- name: Generate AppService Discord invite link - name: Generate AppService Discord invite link
shell: >- ansible.builtin.shell: >-
{{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen {{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--cap-drop=ALL --cap-drop=ALL
@ -101,19 +103,19 @@
changed_when: false changed_when: false
- name: Ensure matrix-appservice-discord.service installed - name: Ensure matrix-appservice-discord.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2" src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-appservice-discord.service" dest: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
mode: 0644 mode: 0644
register: matrix_appservice_discord_systemd_service_result register: matrix_appservice_discord_systemd_service_result
- name: Ensure systemd reloaded after matrix-appservice-discord.service installation - name: Ensure systemd reloaded after matrix-appservice-discord.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_discord_systemd_service_result.changed" when: "matrix_appservice_discord_systemd_service_result.changed"
- name: Ensure matrix-appservice-discord.service restarted, if necessary - name: Ensure matrix-appservice-discord.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-appservice-discord.service" name: "matrix-appservice-discord.service"
state: restarted state: restarted
when: "matrix_appservice_discord_requires_restart|bool" when: "matrix_appservice_discord_requires_restart | bool"

View File

@ -1,12 +1,12 @@
--- ---
- name: Check existence of matrix-appservice-discord service - name: Check existence of matrix-appservice-discord service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service" path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
register: matrix_appservice_discord_service_stat register: matrix_appservice_discord_service_stat
- name: Ensure matrix-appservice-discord is stopped - name: Ensure matrix-appservice-discord is stopped
service: ansible.builtin.service:
name: matrix-appservice-discord name: matrix-appservice-discord
state: stopped state: stopped
enabled: false enabled: false
@ -14,12 +14,12 @@
when: "matrix_appservice_discord_service_stat.stat.exists" when: "matrix_appservice_discord_service_stat.stat.exists"
- name: Ensure matrix-appservice-discord.service doesn't exist - name: Ensure matrix-appservice-discord.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service" path: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
state: absent state: absent
when: "matrix_appservice_discord_service_stat.stat.exists" when: "matrix_appservice_discord_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-appservice-discord.service removal - name: Ensure systemd reloaded after matrix-appservice-discord.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_discord_service_stat.stat.exists" when: "matrix_appservice_discord_service_stat.stat.exists"

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
@ -13,7 +13,7 @@
- "matrix_appservice_discord_homeserver_domain" - "matrix_appservice_discord_homeserver_domain"
- name: (Deprecation) Catch and report renamed appservice-discord variables - name: (Deprecation) Catch and report renamed appservice-discord variables
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). 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>'} - {'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 - 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']" when: "matrix_appservice_discord_database_engine not in ['sqlite', 'postgres']"

View File

@ -34,7 +34,7 @@ bridge:
determineCodeLanguage: false determineCodeLanguage: false
# Authentication configuration for the discord bot. # Authentication configuration for the discord bot.
auth: 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 }} 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) # 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 # for this to work

View File

@ -6,10 +6,14 @@ matrix_appservice_irc_enabled: true
matrix_appservice_irc_container_image_self_build: false 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: "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_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-irc/docker-src"
matrix_appservice_irc_version: release-0.34.0 # matrix_appservice_irc_version used to contain the full Docker image tag (e.g. `release-X.X.X`).
matrix_appservice_irc_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-irc:{{ matrix_appservice_irc_version }}" # 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_docker_image_force_pull: "{{ matrix_appservice_irc_docker_image.endswith(':latest') }}"
matrix_appservice_irc_base_path: "{{ matrix_base_data_path }}/appservice-irc" 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_url: "{{ matrix_homeserver_container_url }}"
matrix_appservice_irc_homeserver_media_url: 'https://{{ matrix_server_fqn_matrix }}' matrix_appservice_irc_homeserver_media_url: 'https://{{ matrix_server_fqn_matrix }}'
matrix_appservice_irc_homeserver_domain: '{{ matrix_domain }}' 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_appservice_address: 'http://matrix-appservice-irc:9999'
matrix_appservice_irc_database_engine: nedb 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' 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. # This is what actually goes into `database.connectionString` for the bridge.
matrix_appservice_irc_database_connectionString: "{{ matrix_appservice_irc_database_connectionString: |- # noqa var-naming
{ {{
'nedb': 'nedb:///data', {
'postgres': matrix_appservice_irc_database_connection_string, 'nedb': 'nedb:///data',
}[matrix_appservice_irc_database_engine] '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): # 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 # If you need something more special, you can take full control by
# completely redefining `matrix_appservice_irc_configuration_yaml`. # 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, # 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. # 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 }}" as_token: "{{ matrix_appservice_irc_appservice_token }}"
hs_token: "{{ matrix_appservice_irc_homeserver_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 }}"

View File

@ -2,35 +2,35 @@
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
- name: Fail if trying to self-build on Ansible < 2.8 - name: Fail if trying to self-build on Ansible < 2.8
fail: ansible.builtin.fail:
msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" msg: "To self-build the Element 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" 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. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-irc role needs to execute before the matrix-synapse role. 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'] }}" 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. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_appservice_irc_config_path }}/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro"] ["--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: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-appservice-irc-registration.yaml"] ["/matrix-appservice-irc-registration.yaml"]
}} }}
when: matrix_appservice_irc_enabled|bool when: matrix_appservice_irc_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_appservice_irc_enabled|bool" when: "run_setup | bool and matrix_appservice_irc_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-irc - setup-appservice-irc
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_appservice_irc_enabled|bool" when: "run_setup | bool and matrix_appservice_irc_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-irc - setup-appservice-irc
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_appservice_irc_enabled|bool" when: "run_setup | bool and not matrix_appservice_irc_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-irc - setup-appservice-irc

View File

@ -1,46 +1,46 @@
--- ---
- name: Fail if Postgres not enabled - 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." 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 # Defaults
- name: Set postgres_start_wait_time, if not provided - name: Set postgres_start_wait_time, if not provided
set_fact: ansible.builtin.set_fact:
postgres_start_wait_time: 15 postgres_start_wait_time: 15
when: "postgres_start_wait_time|default('') == ''" when: "postgres_start_wait_time | default('') == ''"
# Actual import work # Actual import work
- name: Ensure matrix-postgres is started - name: Ensure matrix-postgres is started
service: ansible.builtin.service:
name: matrix-postgres name: matrix-postgres
state: started state: started
daemon_reload: true daemon_reload: true
register: matrix_postgres_service_start_result register: matrix_postgres_service_start_result
- name: Wait a bit, so that Postgres can start - name: Wait a bit, so that Postgres can start
wait_for: ansible.builtin.wait_for:
timeout: "{{ postgres_start_wait_time }}" timeout: "{{ postgres_start_wait_time }}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false 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 - name: Check existence of matrix-appservice-irc service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
register: matrix_appservice_irc_service_stat register: matrix_appservice_irc_service_stat
- name: Ensure matrix-appservice-irc is stopped - name: Ensure matrix-appservice-irc is stopped
service: ansible.builtin.service:
name: matrix-appservice-irc name: matrix-appservice-irc
state: stopped state: stopped
when: "matrix_appservice_irc_service_stat.stat.exists" when: "matrix_appservice_irc_service_stat.stat.exists"
- name: Import appservice-irc NeDB database into Postgres - name: Import appservice-irc NeDB database into Postgres
command: ansible.builtin.command:
cmd: >- cmd: >-
{{ matrix_host_command_docker }} run {{ matrix_host_command_docker }} run
--rm --rm
@ -52,19 +52,23 @@
{{ matrix_appservice_irc_docker_image }} {{ matrix_appservice_irc_docker_image }}
-c -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 }}' '/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 - name: Archive NeDB database files
command: ansible.builtin.command:
cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup" cmd: "mv {{ matrix_appservice_irc_data_path }}/{{ item }} {{ matrix_appservice_irc_data_path }}/{{ item }}.backup"
with_items: with_items:
- rooms.db - rooms.db
- users.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 - name: Inject result
set_fact: ansible.builtin.set_fact:
matrix_playbook_runtime_results: | 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." "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."

View File

@ -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 - name: Ensure Appservice IRC paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -14,47 +14,53 @@
- {path: "{{ matrix_appservice_irc_config_path }}", when: true} - {path: "{{ matrix_appservice_irc_config_path }}", when: true}
- {path: "{{ matrix_appservice_irc_data_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 }}"} - {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 - name: Check if an old passkey file already exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_irc_base_path }}/passkey.pem" path: "{{ matrix_appservice_irc_base_path }}/passkey.pem"
register: matrix_appservice_irc_stat_passkey register: matrix_appservice_irc_stat_passkey
- block: - block:
- name: (Data relocation) Ensure matrix-appservice-irc.service is stopped - name: (Data relocation) Ensure matrix-appservice-irc.service is stopped
service: ansible.builtin.service:
name: matrix-appservice-irc name: matrix-appservice-irc
state: stopped state: stopped
daemon_reload: true daemon_reload: true
failed_when: false failed_when: false
- name: (Data relocation) Move AppService IRC passkey.pem file to ./data directory - 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 - 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: with_items:
- rooms.db - rooms.db
- users.db - users.db
failed_when: false failed_when: false
when: "matrix_appservice_irc_stat_passkey.stat.exists" when: "matrix_appservice_irc_stat_passkey.stat.exists"
- set_fact: - ansible.builtin.set_fact:
matrix_appservice_irc_requires_restart: false matrix_appservice_irc_requires_restart: false
- block: - block:
- name: Check if a nedb database already exists - name: Check if a nedb database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_irc_data_path }}/users.db" path: "{{ matrix_appservice_irc_data_path }}/users.db"
register: matrix_appservice_irc_nedb_database_path_local_stat_result register: matrix_appservice_irc_nedb_database_path_local_stat_result
- block: - 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 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'" when: "matrix_appservice_irc_database_engine == 'postgres'"
- name: Ensure Appservice IRC image is pulled - 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 }}" 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_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 }}" 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 register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure matrix-appservice-irc repository is present when self-building - name: Ensure matrix-appservice-irc repository is present when self-building
git: ansible.builtin.git:
repo: "{{ matrix_appservice_irc_docker_repo }}" repo: "{{ matrix_appservice_irc_docker_repo }}"
version: "{{ matrix_appservice_irc_docker_repo_version }}"
dest: "{{ matrix_appservice_irc_docker_src_files_path }}" dest: "{{ matrix_appservice_irc_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_appservice_irc_git_pull_results 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 - name: Ensure matrix-appservice-irc Docker image is built
docker_image: docker_image:
@ -89,23 +96,23 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_appservice_irc_docker_src_files_path }}" path: "{{ matrix_appservice_irc_docker_src_files_path }}"
pull: true 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 - name: Ensure Matrix Appservice IRC config installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_irc_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_irc_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_irc_config_path }}/config.yaml" dest: "{{ matrix_appservice_irc_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Check if Appservice IRC passkey exists - name: Check if Appservice IRC passkey exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_irc_data_path }}/passkey.pem" path: "{{ matrix_appservice_irc_data_path }}/passkey.pem"
register: irc_passkey_file register: irc_passkey_file
- name: Generate Appservice IRC passkey if it doesn't exist - 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: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
when: "not irc_passkey_file.stat.exists" 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. # In the past, we used to generate the passkey.pem file with root, so permissions may not be okay.
# Fix it. # Fix it.
- name: (Migration) Ensure Appservice IRC passkey permissions are okay - name: (Migration) Ensure Appservice IRC passkey permissions are okay
file: ansible.builtin.file:
path: "{{ matrix_appservice_irc_data_path }}/passkey.pem" path: "{{ matrix_appservice_irc_data_path }}/passkey.pem"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
@ -139,7 +146,7 @@
# an up-to-date file, and we fix it up with some static values later on, # 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. # to produce a final registration.yaml file, as we desire.
- name: Generate Appservice IRC registration-template.yaml - name: Generate Appservice IRC registration-template.yaml
shell: >- ansible.builtin.shell: >-
{{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc-gen {{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc-gen
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--cap-drop=ALL --cap-drop=ALL
@ -157,46 +164,46 @@
changed_when: false changed_when: false
- name: Read Appservice IRC registration-template.yaml - name: Read Appservice IRC registration-template.yaml
slurp: ansible.builtin.slurp:
src: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml" src: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml"
register: matrix_appservice_irc_registration_template_slurp register: matrix_appservice_irc_registration_template_slurp
- name: Remove unnecessary Appservice IRC registration-template.yaml - name: Remove unnecessary Appservice IRC registration-template.yaml
file: ansible.builtin.file:
path: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml" path: "{{ matrix_appservice_irc_config_path }}/registration-template.yaml"
state: absent state: absent
changed_when: false changed_when: false
- name: Parse registration-template.yaml - 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 }}" 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 - name: Combine registration-template.yaml and own registration override config
set_fact: ansible.builtin.set_fact:
matrix_appservice_irc_registration: "{{ matrix_appservice_irc_registration_template|combine(matrix_appservice_irc_registration_override, recursive=True) }}" matrix_appservice_irc_registration: "{{ matrix_appservice_irc_registration_template | combine(matrix_appservice_irc_registration_override, recursive=True) }}"
- name: Ensure Appservice IRC registration.yaml installed - name: Ensure Appservice IRC registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_irc_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_irc_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_irc_config_path }}/registration.yaml" dest: "{{ matrix_appservice_irc_config_path }}/registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-appservice-irc.service installed - name: Ensure matrix-appservice-irc.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-appservice-irc.service.j2" src: "{{ role_path }}/templates/systemd/matrix-appservice-irc.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" dest: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
mode: 0644 mode: 0644
register: matrix_appservice_irc_systemd_service_result register: matrix_appservice_irc_systemd_service_result
- name: Ensure systemd reloaded after matrix-appservice-irc.service installation - name: Ensure systemd reloaded after matrix-appservice-irc.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_irc_systemd_service_result.changed" when: "matrix_appservice_irc_systemd_service_result.changed"
- name: Ensure matrix-appservice-irc.service restarted, if necessary - name: Ensure matrix-appservice-irc.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-appservice-irc.service" name: "matrix-appservice-irc.service"
state: restarted state: restarted
when: "matrix_appservice_irc_requires_restart|bool" when: "matrix_appservice_irc_requires_restart | bool"

View File

@ -1,12 +1,12 @@
--- ---
- name: Check existence of matrix-appservice-irc service - name: Check existence of matrix-appservice-irc service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
register: matrix_appservice_irc_service_stat register: matrix_appservice_irc_service_stat
- name: Ensure matrix-appservice-irc is stopped - name: Ensure matrix-appservice-irc is stopped
service: ansible.builtin.service:
name: matrix-appservice-irc name: matrix-appservice-irc
state: stopped state: stopped
enabled: false enabled: false
@ -14,12 +14,12 @@
when: "matrix_appservice_irc_service_stat.stat.exists" when: "matrix_appservice_irc_service_stat.stat.exists"
- name: Ensure matrix-appservice-irc.service doesn't exist - name: Ensure matrix-appservice-irc.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service" path: "{{ matrix_systemd_path }}/matrix-appservice-irc.service"
state: absent state: absent
when: "matrix_appservice_irc_service_stat.stat.exists" when: "matrix_appservice_irc_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-appservice-irc.service removal - name: Ensure systemd reloaded after matrix-appservice-irc.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_irc_service_stat.stat.exists" when: "matrix_appservice_irc_service_stat.stat.exists"

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
@ -17,7 +17,7 @@
# #
# This is a safety check to ensure we fail earlier and in a nicer way. # This is a safety check to ensure we fail earlier and in a nicer way.
- name: Fail if no additional configuration provided - name: Fail if no additional configuration provided
fail: ansible.builtin.fail:
msg: >- msg: >-
Your Appservice IRC configuration is incomplete (lacking an `ircService.servers` configuration). 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` 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" when: "matrix_appservice_irc_configuration.ircService.servers|length == 0"
- name: (Deprecation) Catch and report renamed appservice-irc variables - name: (Deprecation) Catch and report renamed appservice-irc variables
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).

View File

@ -6,10 +6,14 @@ matrix_appservice_slack_enabled: true
matrix_appservice_slack_container_image_self_build: false 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: "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_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-slack/docker-src"
matrix_appservice_slack_version: release-1.11.0 # matrix_appservice_slack_version used to contain the full Docker image tag (e.g. `release-X.X.X`).
matrix_appservice_slack_docker_image: "{{ matrix_container_global_registry_prefix }}matrixdotorg/matrix-appservice-slack:{{ matrix_appservice_slack_version }}" # 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_docker_image_force_pull: "{{ matrix_appservice_slack_docker_image.endswith(':latest') }}"
matrix_appservice_slack_base_path: "{{ matrix_base_data_path }}/appservice-slack" 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' 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. # This is what actually goes into `database.connectionString` for the bridge.
matrix_appservice_slack_database_connectionString: "{{ matrix_appservice_slack_database_connectionString: |- # noqa var-naming
{ {{
'nedb': 'nedb:///data', {
'postgres': matrix_appservice_slack_database_connection_string, 'nedb': 'nedb:///data',
}[matrix_appservice_slack_database_engine] 'postgres': matrix_appservice_slack_database_connection_string,
}}" }[matrix_appservice_slack_database_engine]
}}
matrix_appservice_slack_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}" matrix_appservice_slack_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"
@ -95,9 +100,9 @@ matrix_appservice_slack_configuration_extension_yaml: |
# - "./debug.log": "info" # - "./debug.log": "info"
#- "./error.log": "error" #- "./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: | matrix_appservice_slack_registration_yaml: |
id: "{{ matrix_appservice_slack_id_token }}" id: "{{ matrix_appservice_slack_id_token }}"
@ -111,9 +116,9 @@ matrix_appservice_slack_registration_yaml: |
- exclusive: false - exclusive: false
regex: '#{{ matrix_appservice_slack_user_prefix }}.*' regex: '#{{ matrix_appservice_slack_user_prefix }}.*'
rooms: [] 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 sender_localpart: slackbot
rate_limited: true rate_limited: true
protocols: null protocols: null
matrix_appservice_slack_registration: "{{ matrix_appservice_slack_registration_yaml|from_yaml }}" matrix_appservice_slack_registration: "{{ matrix_appservice_slack_registration_yaml | from_yaml }}"

View File

@ -2,62 +2,62 @@
# See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070 # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
# and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407 # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
- name: Fail if trying to self-build on Ansible < 2.8 - name: Fail if trying to self-build on Ansible < 2.8
fail: ansible.builtin.fail:
msg: "To self-build the Element image, you should use Ansible 2.8 or higher. See docs/ansible.md" msg: "To self-build the Element 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_slack_container_image_self_build and matrix_appservice_slack_enabled" when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_slack_container_image_self_build and matrix_appservice_slack_enabled"
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role. The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-slack.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-slack.service'] }}"
when: matrix_appservice_slack_enabled|bool when: matrix_appservice_slack_enabled | bool
# If the matrix-synapse role is not used, these variables may not exist. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_appservice_slack_config_path }}/slack-registration.yaml,dst=/matrix-appservice-slack-registration.yaml,ro"] ["--mount type=bind,src={{ matrix_appservice_slack_config_path }}/slack-registration.yaml,dst=/matrix-appservice-slack-registration.yaml,ro"]
}} }}
matrix_synapse_app_service_config_files: > matrix_synapse_app_service_config_files: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-appservice-slack-registration.yaml"] ["/matrix-appservice-slack-registration.yaml"]
}} }}
when: matrix_appservice_slack_enabled|bool when: matrix_appservice_slack_enabled | bool
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role. The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- block: - block:
- name: Fail if matrix-nginx-proxy role already executed - name: Fail if matrix-nginx-proxy role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
Trying to append Slack Appservice's reverse-proxying configuration to matrix-nginx-proxy, Trying to append Slack Appservice's reverse-proxying configuration to matrix-nginx-proxy,
but it's pointless since the matrix-nginx-proxy role had already executed. but it's pointless since the matrix-nginx-proxy role had already executed.
To fix this, please change the order of roles in your playbook, To fix this, please change the order of roles in your playbook,
so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-slack role. so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-slack role.
when: matrix_nginx_proxy_role_executed|default(False)|bool when: matrix_nginx_proxy_role_executed | default(False) | bool
- name: Generate Matrix Appservice Slack proxying configuration for matrix-nginx-proxy - name: Generate Matrix Appservice Slack proxying configuration for matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_appservice_slack_matrix_nginx_proxy_configuration: | matrix_appservice_slack_matrix_nginx_proxy_configuration: |
location {{ matrix_appservice_slack_public_endpoint }} { location {{ matrix_appservice_slack_public_endpoint }} {
{% if matrix_nginx_proxy_enabled|default(False) %} {% if matrix_nginx_proxy_enabled | default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #} {# Use the embedded DNS resolver in Docker containers to discover the service #}
resolver 127.0.0.11 valid=5s; resolver 127.0.0.11 valid=5s;
set $backend "{{ matrix_appservice_slack_appservice_url }}:{{ matrix_appservice_slack_slack_port }}"; set $backend "{{ matrix_appservice_slack_appservice_url }}:{{ matrix_appservice_slack_slack_port }}";
@ -69,23 +69,23 @@
} }
- name: Register Slack Appservice proxying configuration with matrix-nginx-proxy - name: Register Slack Appservice proxying configuration with matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
{{ {{
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
+ +
[matrix_appservice_slack_matrix_nginx_proxy_configuration] [matrix_appservice_slack_matrix_nginx_proxy_configuration]
}} }}
tags: tags:
- always - always
when: matrix_appservice_slack_enabled|bool when: matrix_appservice_slack_enabled | bool
- name: Warn about reverse-proxying if matrix-nginx-proxy not used - name: Warn about reverse-proxying if matrix-nginx-proxy not used
debug: ansible.builtin.debug:
msg: >- msg: >-
NOTE: You've enabled the Matrix Slack bridge but are not using the matrix-nginx-proxy NOTE: You've enabled the Matrix Slack bridge but are not using the matrix-nginx-proxy
reverse proxy. reverse proxy.
Please make sure that you're proxying the `{{ something }}` Please make sure that you're proxying the `{{ something }}`
URL endpoint to the matrix-appservice-slack container. URL endpoint to the matrix-appservice-slack container.
You can expose the container's port using the `matrix_appservice_slack_container_http_host_bind_port` variable. You can expose the container's port using the `matrix_appservice_slack_container_http_host_bind_port` variable.
when: "matrix_appservice_slack_enabled|bool and not matrix_nginx_proxy_enabled|default(False)|bool" when: "matrix_appservice_slack_enabled | bool and not matrix_nginx_proxy_enabled | default(False) | bool"

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_appservice_slack_enabled|bool" when: "run_setup | bool and matrix_appservice_slack_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-slack - setup-appservice-slack
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_appservice_slack_enabled|bool" when: "run_setup | bool and matrix_appservice_slack_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-slack - setup-appservice-slack
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_appservice_slack_enabled|bool" when: "run_setup | bool and not matrix_appservice_slack_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-slack - setup-appservice-slack

View File

@ -1,40 +1,40 @@
--- ---
- name: Fail if Postgres not enabled - 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." 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 # Defaults
- name: Set postgres_start_wait_time, if not provided - name: Set postgres_start_wait_time, if not provided
set_fact: ansible.builtin.set_fact:
postgres_start_wait_time: 15 postgres_start_wait_time: 15
when: "postgres_start_wait_time|default('') == ''" when: "postgres_start_wait_time | default('') == ''"
# Actual import work # Actual import work
- name: Ensure matrix-postgres is started - name: Ensure matrix-postgres is started
service: ansible.builtin.service:
name: matrix-postgres name: matrix-postgres
state: started state: started
daemon_reload: true daemon_reload: true
register: matrix_postgres_service_start_result register: matrix_postgres_service_start_result
- name: Wait a bit, so that Postgres can start - name: Wait a bit, so that Postgres can start
wait_for: ansible.builtin.wait_for:
timeout: "{{ postgres_start_wait_time }}" timeout: "{{ postgres_start_wait_time }}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
become: false become: false
when: "matrix_postgres_service_start_result.changed|bool" when: "matrix_postgres_service_start_result.changed | bool"
- name: Ensure matrix-appservice-slack is stopped - name: Ensure matrix-appservice-slack is stopped
service: ansible.builtin.service:
name: matrix-appservice-slack name: matrix-appservice-slack
state: stopped state: stopped
- name: Import appservice-slack NeDB database into Postgres - name: Import appservice-slack NeDB database into Postgres
command: ansible.builtin.command:
cmd: >- cmd: >-
{{ matrix_host_command_docker }} run {{ matrix_host_command_docker }} run
--rm --rm
@ -46,10 +46,14 @@
{{ matrix_appservice_slack_docker_image }} {{ matrix_appservice_slack_docker_image }}
-c -c
'/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}' '/usr/local/bin/node /usr/src/app/lib/scripts/migrateToPostgres.js --dbdir /data --connectionString {{ matrix_appservice_slack_database_connection_string }}'
register: matrix_appservice_slack_import_nedb_to_postgres_result
changed_when: matrix_appservice_slack_import_nedb_to_postgres_result.rc == 0
- name: Archive NeDB database files - name: Archive NeDB database files
command: ansible.builtin.command:
cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup" cmd: "mv {{ matrix_appservice_slack_data_path }}/{{ item }} {{ matrix_appservice_slack_data_path }}/{{ item }}.backup"
register: matrix_appservice_slack_import_nedb_to_postgres_move_result
changed_when: matrix_appservice_slack_import_nedb_to_postgres_move_result.rc == 0
with_items: with_items:
- teams.db - teams.db
- room-store.db - room-store.db
@ -57,10 +61,10 @@
- event-store.db - event-store.db
- name: Inject result - name: Inject result
set_fact: ansible.builtin.set_fact:
matrix_playbook_runtime_results: | matrix_playbook_runtime_results: |
{{ {{
matrix_playbook_runtime_results|default([]) matrix_playbook_runtime_results | default([])
+ +
[ [
"NOTE: Your appservice-slack database files have been imported into Postgres. The original database files have been moved from `{{ matrix_appservice_slack_data_path }}/*.db` to `{{ matrix_appservice_slack_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." "NOTE: Your appservice-slack database files have been imported into Postgres. The original database files have been moved from `{{ matrix_appservice_slack_data_path }}/*.db` to `{{ matrix_appservice_slack_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."

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure AppService Slack paths exist - name: Ensure AppService Slack paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -12,23 +12,23 @@
- {path: "{{ matrix_appservice_slack_config_path }}", when: true} - {path: "{{ matrix_appservice_slack_config_path }}", when: true}
- {path: "{{ matrix_appservice_slack_data_path }}", when: true} - {path: "{{ matrix_appservice_slack_data_path }}", when: true}
- {path: "{{ matrix_appservice_slack_docker_src_files_path }}", when: "{{ matrix_appservice_slack_container_image_self_build }}"} - {path: "{{ matrix_appservice_slack_docker_src_files_path }}", when: "{{ matrix_appservice_slack_container_image_self_build }}"}
when: item.when|bool when: item.when | bool
- set_fact: - ansible.builtin.set_fact:
matrix_appservice_slack_requires_restart: false matrix_appservice_slack_requires_restart: false
- block: - block:
- name: Check if a nedb database already exists - name: Check if a nedb database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_appservice_slack_data_path }}/teams.db" path: "{{ matrix_appservice_slack_data_path }}/teams.db"
register: matrix_appservice_slack_nedb_database_path_local_stat_result register: matrix_appservice_slack_nedb_database_path_local_stat_result
- block: - 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_slack_requires_restart: true matrix_appservice_slack_requires_restart: true
when: "matrix_appservice_slack_nedb_database_path_local_stat_result.stat.exists|bool" when: "matrix_appservice_slack_nedb_database_path_local_stat_result.stat.exists | bool"
when: "matrix_appservice_slack_database_engine == 'postgres'" when: "matrix_appservice_slack_database_engine == 'postgres'"
- name: Ensure Appservice Slack image is pulled - name: Ensure Appservice Slack image is pulled
@ -37,21 +37,22 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_appservice_slack_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force_source: "{{ matrix_appservice_slack_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_slack_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_slack_docker_image_force_pull }}"
when: "not matrix_appservice_slack_container_image_self_build|bool" when: "not matrix_appservice_slack_container_image_self_build | bool"
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure matrix-appservice-slack repository is present when self-building - name: Ensure matrix-appservice-slack repository is present when self-building
git: ansible.builtin.git:
repo: "{{ matrix_appservice_slack_docker_repo }}" repo: "{{ matrix_appservice_slack_docker_repo }}"
version: "{{ matrix_appservice_slack_docker_repo_version }}"
dest: "{{ matrix_appservice_slack_docker_src_files_path }}" dest: "{{ matrix_appservice_slack_docker_src_files_path }}"
force: "yes" force: "yes"
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_appservice_slack_git_pull_results register: matrix_appservice_slack_git_pull_results
when: "matrix_appservice_slack_container_image_self_build|bool" when: "matrix_appservice_slack_container_image_self_build | bool"
- name: Ensure matrix-appservice-slack Docker image is built - name: Ensure matrix-appservice-slack Docker image is built
docker_image: docker_image:
@ -63,38 +64,38 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_appservice_slack_docker_src_files_path }}" path: "{{ matrix_appservice_slack_docker_src_files_path }}"
pull: true pull: true
when: "matrix_appservice_slack_container_image_self_build|bool and matrix_appservice_slack_git_pull_results.changed" when: "matrix_appservice_slack_container_image_self_build | bool and matrix_appservice_slack_git_pull_results.changed"
- name: Ensure Matrix Appservice Slack config installed - name: Ensure Matrix Appservice Slack config installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_slack_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_slack_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_slack_config_path }}/config.yaml" dest: "{{ matrix_appservice_slack_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure appservice-slack registration.yaml installed - name: Ensure appservice-slack registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_slack_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_slack_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_slack_config_path }}/slack-registration.yaml" dest: "{{ matrix_appservice_slack_config_path }}/slack-registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-appservice-slack.service installed - name: Ensure matrix-appservice-slack.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-appservice-slack.service.j2" src: "{{ role_path }}/templates/systemd/matrix-appservice-slack.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-appservice-slack.service" dest: "{{ matrix_systemd_path }}/matrix-appservice-slack.service"
mode: 0644 mode: 0644
register: matrix_appservice_slack_systemd_service_result register: matrix_appservice_slack_systemd_service_result
- name: Ensure systemd reloaded after matrix-appservice-slack.service installation - name: Ensure systemd reloaded after matrix-appservice-slack.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_slack_systemd_service_result.changed" when: "matrix_appservice_slack_systemd_service_result.changed"
- name: Ensure matrix-appservice-slack.service restarted, if necessary - name: Ensure matrix-appservice-slack.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-appservice-slack.service" name: "matrix-appservice-slack.service"
state: restarted state: restarted
when: "matrix_appservice_slack_requires_restart|bool" when: "matrix_appservice_slack_requires_restart | bool"

View File

@ -1,12 +1,12 @@
--- ---
- name: Check existence of matrix-appservice-slack service - name: Check existence of matrix-appservice-slack service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-appservice-slack.service" path: "{{ matrix_systemd_path }}/matrix-appservice-slack.service"
register: matrix_appservice_slack_service_stat register: matrix_appservice_slack_service_stat
- name: Ensure matrix-appservice-slack is stopped - name: Ensure matrix-appservice-slack is stopped
service: ansible.builtin.service:
name: matrix-appservice-slack name: matrix-appservice-slack
state: stopped state: stopped
enabled: false enabled: false
@ -14,12 +14,12 @@
when: "matrix_appservice_slack_service_stat.stat.exists" when: "matrix_appservice_slack_service_stat.stat.exists"
- name: Ensure matrix-appservice-slack.service doesn't exist - name: Ensure matrix-appservice-slack.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-appservice-slack.service" path: "{{ matrix_systemd_path }}/matrix-appservice-slack.service"
state: absent state: absent
when: "matrix_appservice_slack_service_stat.stat.exists" when: "matrix_appservice_slack_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-appservice-slack.service removal - name: Ensure systemd reloaded after matrix-appservice-slack.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_slack_service_stat.stat.exists" when: "matrix_appservice_slack_service_stat.stat.exists"

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
@ -13,7 +13,7 @@
- "matrix_appservice_slack_id_token" - "matrix_appservice_slack_id_token"
- name: (Deprecation) Catch and report renamed settings - name: (Deprecation) Catch and report renamed settings
fail: ansible.builtin.fail:
msg: >- msg: >-
Your configuration contains a variable, which now has a different name. Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`). Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).

View File

@ -61,9 +61,9 @@ matrix_appservice_webhooks_configuration_yaml: "{{ lookup('template', 'templates
matrix_appservice_webhooks_configuration_extension_yaml: | matrix_appservice_webhooks_configuration_extension_yaml: |
# #
matrix_appservice_webhooks_configuration_extension: "{{ matrix_appservice_webhooks_configuration_extension_yaml|from_yaml if matrix_appservice_webhooks_configuration_extension_yaml|from_yaml else {} }}" matrix_appservice_webhooks_configuration_extension: "{{ matrix_appservice_webhooks_configuration_extension_yaml | from_yaml if matrix_appservice_webhooks_configuration_extension_yaml | from_yaml else {} }}"
matrix_appservice_webhooks_configuration: "{{ matrix_appservice_webhooks_configuration_yaml|from_yaml|combine(matrix_appservice_webhooks_configuration_extension, recursive=True) }}" matrix_appservice_webhooks_configuration: "{{ matrix_appservice_webhooks_configuration_yaml | from_yaml | combine(matrix_appservice_webhooks_configuration_extension, recursive=True) }}"
matrix_appservice_webhooks_registration_yaml: | matrix_appservice_webhooks_registration_yaml: |
id: "{{ matrix_appservice_webhooks_id_token }}" id: "{{ matrix_appservice_webhooks_id_token }}"
@ -80,4 +80,4 @@ matrix_appservice_webhooks_registration_yaml: |
rate_limited: false rate_limited: false
protocols: null protocols: null
matrix_appservice_webhooks_registration: "{{ matrix_appservice_webhooks_registration_yaml|from_yaml }}" matrix_appservice_webhooks_registration: "{{ matrix_appservice_webhooks_registration_yaml | from_yaml }}"

View File

@ -2,54 +2,54 @@
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role. The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-webhooks.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-webhooks.service'] }}"
when: matrix_appservice_webhooks_enabled|bool when: matrix_appservice_webhooks_enabled | bool
# If the matrix-synapse role is not used, these variables may not exist. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_appservice_webhooks_config_path }}/webhooks-registration.yaml,dst=/matrix-appservice-webhooks-registration.yaml,ro"] ["--mount type=bind,src={{ matrix_appservice_webhooks_config_path }}/webhooks-registration.yaml,dst=/matrix-appservice-webhooks-registration.yaml,ro"]
}} }}
matrix_synapse_app_service_config_files: > matrix_synapse_app_service_config_files: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-appservice-webhooks-registration.yaml"] ["/matrix-appservice-webhooks-registration.yaml"]
}} }}
when: matrix_appservice_webhooks_enabled|bool when: matrix_appservice_webhooks_enabled | bool
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role. The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- block: - block:
- name: Fail if matrix-nginx-proxy role already executed - name: Fail if matrix-nginx-proxy role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
Trying to append webhooks Appservice's reverse-proxying configuration to matrix-nginx-proxy, Trying to append webhooks Appservice's reverse-proxying configuration to matrix-nginx-proxy,
but it's pointless since the matrix-nginx-proxy role had already executed. but it's pointless since the matrix-nginx-proxy role had already executed.
To fix this, please change the order of roles in your playbook, To fix this, please change the order of roles in your playbook,
so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-webhooks role. so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-webhooks role.
when: matrix_nginx_proxy_role_executed|default(False)|bool when: matrix_nginx_proxy_role_executed | default(False) | bool
- name: Generate Matrix Appservice webhooks proxying configuration for matrix-nginx-proxy - name: Generate Matrix Appservice webhooks proxying configuration for matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_appservice_webhooks_matrix_nginx_proxy_configuration: | matrix_appservice_webhooks_matrix_nginx_proxy_configuration: |
{% if matrix_nginx_proxy_enabled|default(False) %} {% if matrix_nginx_proxy_enabled | default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #} {# Use the embedded DNS resolver in Docker containers to discover the service #}
location ~ ^{{ matrix_appservice_webhooks_public_endpoint }}/(.*)$ { location ~ ^{{ matrix_appservice_webhooks_public_endpoint }}/(.*)$ {
resolver 127.0.0.11 valid=5s; resolver 127.0.0.11 valid=5s;
@ -64,23 +64,23 @@
{% endif %} {% endif %}
- name: Register webhooks Appservice proxying configuration with matrix-nginx-proxy - name: Register webhooks Appservice proxying configuration with matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
{{ {{
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
+ +
[matrix_appservice_webhooks_matrix_nginx_proxy_configuration] [matrix_appservice_webhooks_matrix_nginx_proxy_configuration]
}} }}
tags: tags:
- always - always
when: matrix_appservice_webhooks_enabled|bool when: matrix_appservice_webhooks_enabled | bool
- name: Warn about reverse-proxying if matrix-nginx-proxy not used - name: Warn about reverse-proxying if matrix-nginx-proxy not used
debug: ansible.builtin.debug:
msg: >- msg: >-
NOTE: You've enabled the Matrix webhooks bridge but are not using the matrix-nginx-proxy NOTE: You've enabled the Matrix webhooks bridge but are not using the matrix-nginx-proxy
reverse proxy. reverse proxy.
Please make sure that you're proxying the `{{ matrix_appservice_webhooks_public_endpoint }}` Please make sure that you're proxying the `{{ matrix_appservice_webhooks_public_endpoint }}`
URL endpoint to the matrix-appservice-webhooks container. URL endpoint to the matrix-appservice-webhooks container.
You can expose the container's port using the `matrix_appservice_webhooks_container_http_host_bind_port` variable. You can expose the container's port using the `matrix_appservice_webhooks_container_http_host_bind_port` variable.
when: "matrix_appservice_webhooks_enabled|bool and not matrix_nginx_proxy_enabled|default(False)|bool" when: "matrix_appservice_webhooks_enabled | bool and not matrix_nginx_proxy_enabled | default(False) | bool"

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_appservice_webhooks_enabled|bool" when: "run_setup | bool and matrix_appservice_webhooks_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-webhooks - setup-appservice-webhooks
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_appservice_webhooks_enabled|bool" when: "run_setup | bool and matrix_appservice_webhooks_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-webhooks - setup-appservice-webhooks
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_appservice_webhooks_enabled|bool" when: "run_setup | bool and not matrix_appservice_webhooks_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-appservice-webhooks - setup-appservice-webhooks

View File

@ -1,7 +1,7 @@
--- ---
- name: Ensure AppService webhooks paths exist - name: Ensure AppService webhooks paths exist
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -12,7 +12,7 @@
- {path: "{{ matrix_appservice_webhooks_config_path }}", when: true} - {path: "{{ matrix_appservice_webhooks_config_path }}", when: true}
- {path: "{{ matrix_appservice_webhooks_data_path }}", when: true} - {path: "{{ matrix_appservice_webhooks_data_path }}", when: true}
- {path: "{{ matrix_appservice_webhooks_docker_src_files_path }}", when: "{{ matrix_appservice_webhooks_container_image_self_build }}"} - {path: "{{ matrix_appservice_webhooks_docker_src_files_path }}", when: "{{ matrix_appservice_webhooks_container_image_self_build }}"}
when: "item.when|bool" when: "item.when | bool"
- name: Ensure Appservice webhooks image is pulled - name: Ensure Appservice webhooks image is pulled
docker_image: docker_image:
@ -20,7 +20,7 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_appservice_webhooks_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force_source: "{{ matrix_appservice_webhooks_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_webhooks_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_webhooks_docker_image_force_pull }}"
when: "not matrix_appservice_webhooks_container_image_self_build|bool" when: "not matrix_appservice_webhooks_container_image_self_build | bool"
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
@ -28,7 +28,7 @@
- block: - block:
- name: Ensure Appservice webhooks repository is present on self-build - name: Ensure Appservice webhooks repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_appservice_webhooks_container_image_self_build_repo }}" repo: "{{ matrix_appservice_webhooks_container_image_self_build_repo }}"
dest: "{{ matrix_appservice_webhooks_docker_src_files_path }}" dest: "{{ matrix_appservice_webhooks_docker_src_files_path }}"
version: "{{ matrix_appservice_webhooks_container_image_self_build_repo_version }}" version: "{{ matrix_appservice_webhooks_container_image_self_build_repo_version }}"
@ -47,18 +47,18 @@
dockerfile: "{{ matrix_appservice_webhooks_container_image_self_build_repo_dockerfile_path }}" dockerfile: "{{ matrix_appservice_webhooks_container_image_self_build_repo_dockerfile_path }}"
path: "{{ matrix_appservice_webhooks_docker_src_files_path }}" path: "{{ matrix_appservice_webhooks_docker_src_files_path }}"
pull: true pull: true
when: "matrix_appservice_webhooks_container_image_self_build|bool" when: "matrix_appservice_webhooks_container_image_self_build | bool"
- name: Ensure Matrix Appservice webhooks config is installed - name: Ensure Matrix Appservice webhooks config is installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_webhooks_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_webhooks_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_webhooks_config_path }}/config.yaml" dest: "{{ matrix_appservice_webhooks_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure Matrix Appservice webhooks schema.yml template exists - name: Ensure Matrix Appservice webhooks schema.yml template exists
template: ansible.builtin.template:
src: "{{ role_path }}/templates/schema.yml.j2" src: "{{ role_path }}/templates/schema.yml.j2"
dest: "{{ matrix_appservice_webhooks_config_path }}/schema.yml" dest: "{{ matrix_appservice_webhooks_config_path }}/schema.yml"
mode: 0644 mode: 0644
@ -66,7 +66,7 @@
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure Matrix Appservice webhooks database.json template exists - name: Ensure Matrix Appservice webhooks database.json template exists
template: ansible.builtin.template:
src: "{{ role_path }}/templates/database.json.j2" src: "{{ role_path }}/templates/database.json.j2"
dest: "{{ matrix_appservice_webhooks_data_path }}/database.json" dest: "{{ matrix_appservice_webhooks_data_path }}/database.json"
mode: 0644 mode: 0644
@ -74,21 +74,21 @@
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure appservice-webhooks registration.yaml installed - name: Ensure appservice-webhooks registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_appservice_webhooks_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_appservice_webhooks_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_appservice_webhooks_config_path }}/webhooks-registration.yaml" dest: "{{ matrix_appservice_webhooks_config_path }}/webhooks-registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-appservice-webhooks.service installed - name: Ensure matrix-appservice-webhooks.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-appservice-webhooks.service.j2" src: "{{ role_path }}/templates/systemd/matrix-appservice-webhooks.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service" dest: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service"
mode: 0644 mode: 0644
register: matrix_appservice_webhooks_systemd_service_result register: matrix_appservice_webhooks_systemd_service_result
- name: Ensure systemd reloaded after matrix-appservice-webhooks.service installation - name: Ensure systemd reloaded after matrix-appservice-webhooks.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_webhooks_systemd_service_result.changed" when: "matrix_appservice_webhooks_systemd_service_result.changed"

View File

@ -1,12 +1,12 @@
--- ---
- name: Check existence of matrix-appservice-webhooks service - name: Check existence of matrix-appservice-webhooks service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service" path: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service"
register: matrix_appservice_webhooks_service_stat register: matrix_appservice_webhooks_service_stat
- name: Ensure matrix-appservice-webhooks is stopped - name: Ensure matrix-appservice-webhooks is stopped
service: ansible.builtin.service:
name: matrix-appservice-webhooks name: matrix-appservice-webhooks
state: stopped state: stopped
enabled: false enabled: false
@ -14,12 +14,12 @@
when: "matrix_appservice_webhooks_service_stat.stat.exists" when: "matrix_appservice_webhooks_service_stat.stat.exists"
- name: Ensure matrix-appservice-webhooks.service doesn't exist - name: Ensure matrix-appservice-webhooks.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service" path: "{{ matrix_systemd_path }}/matrix-appservice-webhooks.service"
state: absent state: absent
when: "matrix_appservice_webhooks_service_stat.stat.exists" when: "matrix_appservice_webhooks_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-appservice-webhooks.service removal - name: Ensure systemd reloaded after matrix-appservice-webhooks.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_appservice_webhooks_service_stat.stat.exists" when: "matrix_appservice_webhooks_service_stat.stat.exists"

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"

View File

@ -88,11 +88,11 @@ matrix_beeper_linkedin_configuration_extension_yaml: |
# If you need something more special, you can take full control by # If you need something more special, you can take full control by
# completely redefining `matrix_beeper_linkedin_configuration_yaml`. # completely redefining `matrix_beeper_linkedin_configuration_yaml`.
matrix_beeper_linkedin_configuration_extension: "{{ matrix_beeper_linkedin_configuration_extension_yaml|from_yaml if matrix_beeper_linkedin_configuration_extension_yaml|from_yaml is mapping else {} }}" matrix_beeper_linkedin_configuration_extension: "{{ matrix_beeper_linkedin_configuration_extension_yaml | from_yaml if matrix_beeper_linkedin_configuration_extension_yaml | from_yaml is mapping else {} }}"
# Holds the final configuration (a combination of the default and its extension). # 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_beeper_linkedin_configuration_yaml`. # You most likely don't need to touch this variable. Instead, see `matrix_beeper_linkedin_configuration_yaml`.
matrix_beeper_linkedin_configuration: "{{ matrix_beeper_linkedin_configuration_yaml|from_yaml|combine(matrix_beeper_linkedin_configuration_extension, recursive=True) }}" matrix_beeper_linkedin_configuration: "{{ matrix_beeper_linkedin_configuration_yaml | from_yaml | combine(matrix_beeper_linkedin_configuration_extension, recursive=True) }}"
matrix_beeper_linkedin_registration_yaml: | matrix_beeper_linkedin_registration_yaml: |
id: linkedin id: linkedin
@ -104,10 +104,10 @@ matrix_beeper_linkedin_registration_yaml: |
rate_limited: false rate_limited: false
namespaces: namespaces:
users: users:
- regex: '^@linkedin_.+:{{ matrix_beeper_linkedin_homeserver_domain|regex_escape }}$' - regex: '^@linkedin_.+:{{ matrix_beeper_linkedin_homeserver_domain | regex_escape }}$'
exclusive: true exclusive: true
- exclusive: true - exclusive: true
regex: '^@{{ matrix_beeper_linkedin_appservice_bot_username|regex_escape }}:{{ matrix_beeper_linkedin_homeserver_domain|regex_escape }}$' regex: '^@{{ matrix_beeper_linkedin_appservice_bot_username | regex_escape }}:{{ matrix_beeper_linkedin_homeserver_domain | regex_escape }}$'
de.sorunome.msc2409.push_ephemeral: true de.sorunome.msc2409.push_ephemeral: true
matrix_beeper_linkedin_registration: "{{ matrix_beeper_linkedin_registration_yaml|from_yaml }}" matrix_beeper_linkedin_registration: "{{ matrix_beeper_linkedin_registration_yaml | from_yaml }}"

View File

@ -1,22 +1,22 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-beeper-linkedin.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-beeper-linkedin.service'] }}"
when: matrix_beeper_linkedin_enabled|bool when: matrix_beeper_linkedin_enabled | bool
# If the matrix-synapse role is not used, these variables may not exist. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_beeper_linkedin_config_path }}/registration.yaml,dst=/matrix-beeper-linkedin-registration.yaml,ro"] ["--mount type=bind,src={{ matrix_beeper_linkedin_config_path }}/registration.yaml,dst=/matrix-beeper-linkedin-registration.yaml,ro"]
}} }}
matrix_synapse_app_service_config_files: > matrix_synapse_app_service_config_files: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-beeper-linkedin-registration.yaml"] ["/matrix-beeper-linkedin-registration.yaml"]
}} }}
when: matrix_beeper_linkedin_enabled|bool when: matrix_beeper_linkedin_enabled | bool

View File

@ -1,22 +1,22 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_beeper_linkedin_enabled|bool" when: "run_setup | bool and matrix_beeper_linkedin_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-beeper-linkedin - setup-beeper-linkedin
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup and matrix_beeper_linkedin_enabled" when: "run_setup and matrix_beeper_linkedin_enabled"
tags: tags:
- setup-all - setup-all
- setup-beeper-linkedin - setup-beeper-linkedin
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup and not matrix_beeper_linkedin_enabled" when: "run_setup and not matrix_beeper_linkedin_enabled"
tags: tags:
- setup-all - setup-all

View File

@ -3,12 +3,12 @@
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-beeper-linkedin role needs to execute before the matrix-synapse role. The matrix-bridge-beeper-linkedin role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- name: Ensure Beeper LinkedIn paths exists - name: Ensure Beeper LinkedIn paths exists
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -19,7 +19,7 @@
- {path: "{{ matrix_beeper_linkedin_config_path }}", when: true} - {path: "{{ matrix_beeper_linkedin_config_path }}", when: true}
- {path: "{{ matrix_beeper_linkedin_data_path }}", when: true} - {path: "{{ matrix_beeper_linkedin_data_path }}", when: true}
- {path: "{{ matrix_beeper_linkedin_docker_src_files_path }}", when: "{{ matrix_beeper_linkedin_container_image_self_build }}"} - {path: "{{ matrix_beeper_linkedin_docker_src_files_path }}", when: "{{ matrix_beeper_linkedin_container_image_self_build }}"}
when: "item.when|bool" when: "item.when | bool"
- name: Ensure Beeper LinkedIn image is pulled - name: Ensure Beeper LinkedIn image is pulled
@ -28,7 +28,7 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_beeper_linkedin_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force_source: "{{ matrix_beeper_linkedin_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_beeper_linkedin_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_beeper_linkedin_docker_image_force_pull }}"
when: "not matrix_beeper_linkedin_container_image_self_build|bool" when: "not matrix_beeper_linkedin_container_image_self_build | bool"
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
@ -36,7 +36,7 @@
- block: - block:
- name: Ensure Beeper LinkedIn repository is present on self-build - name: Ensure Beeper LinkedIn repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_beeper_linkedin_container_image_self_build_repo }}" repo: "{{ matrix_beeper_linkedin_container_image_self_build_repo }}"
dest: "{{ matrix_beeper_linkedin_docker_src_files_path }}" dest: "{{ matrix_beeper_linkedin_docker_src_files_path }}"
version: "{{ matrix_beeper_linkedin_container_image_self_build_branch }}" version: "{{ matrix_beeper_linkedin_container_image_self_build_branch }}"
@ -48,14 +48,17 @@
# Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated. # Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated.
# See: https://gitlab.com/beeper/linkedin/-/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40 # See: https://gitlab.com/beeper/linkedin/-/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40
- name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn Docker Image - name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn Docker Image
command: | ansible.builtin.command:
{{ matrix_host_command_docker }} run \ cmd: |
--rm \ {{ matrix_host_command_docker }} run \
--entrypoint=/bin/sh \ --rm \
--mount type=bind,src={{ matrix_beeper_linkedin_docker_src_files_path }},dst=/work \ --entrypoint=/bin/sh \
-w /work \ --mount type=bind,src={{ matrix_beeper_linkedin_docker_src_files_path }},dst=/work \
docker.io/python:3.9.6-buster \ -w /work \
-c "pip install poetry && poetry export --without-hashes -E e2be -E images -E metrics | sed 's/==.*//g' > docker-requirements.txt" docker.io/python:3.9.6-buster \
-c "pip install poetry && poetry export --without-hashes -E e2be -E images -E metrics | sed 's/==.*//g' > docker-requirements.txt"
register: matrix_beeper_linkedin_generate_docker_requirements_result
changed_when: matrix_beeper_linkedin_generate_docker_requirements_result.rc == 0
- name: Ensure Beeper LinkedIn Docker image is built - name: Ensure Beeper LinkedIn Docker image is built
docker_image: docker_image:
@ -69,32 +72,32 @@
pull: true pull: true
args: args:
TARGETARCH: "{{ matrix_architecture }}" TARGETARCH: "{{ matrix_architecture }}"
when: "matrix_beeper_linkedin_container_image_self_build|bool" when: "matrix_beeper_linkedin_container_image_self_build | bool"
- name: Ensure beeper-linkedin config.yaml installed - name: Ensure beeper-linkedin config.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_beeper_linkedin_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_beeper_linkedin_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_beeper_linkedin_config_path }}/config.yaml" dest: "{{ matrix_beeper_linkedin_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure beeper-linkedin registration.yaml installed - name: Ensure beeper-linkedin registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_beeper_linkedin_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_beeper_linkedin_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_beeper_linkedin_config_path }}/registration.yaml" dest: "{{ matrix_beeper_linkedin_config_path }}/registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-beeper-linkedin.service installed - name: Ensure matrix-beeper-linkedin.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2" src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service" dest: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service"
mode: 0644 mode: 0644
register: matrix_beeper_linkedin_systemd_service_result register: matrix_beeper_linkedin_systemd_service_result
- name: Ensure systemd reloaded after matrix-beeper-linkedin.service installation - name: Ensure systemd reloaded after matrix-beeper-linkedin.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_beeper_linkedin_systemd_service_result.changed" when: "matrix_beeper_linkedin_systemd_service_result.changed"

View File

@ -1,12 +1,12 @@
--- ---
- name: Check existence of matrix-beeper-linkedin service - name: Check existence of matrix-beeper-linkedin service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service" path: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service"
register: matrix_beeper_linkedin_service_stat register: matrix_beeper_linkedin_service_stat
- name: Ensure matrix-beeper-linkedin is stopped - name: Ensure matrix-beeper-linkedin is stopped
service: ansible.builtin.service:
name: matrix-beeper-linkedin name: matrix-beeper-linkedin
state: stopped state: stopped
enabled: false enabled: false
@ -14,12 +14,12 @@
when: "matrix_beeper_linkedin_service_stat.stat.exists" when: "matrix_beeper_linkedin_service_stat.stat.exists"
- name: Ensure matrix-beeper-linkedin.service doesn't exist - name: Ensure matrix-beeper-linkedin.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service" path: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service"
state: absent state: absent
when: "matrix_beeper_linkedin_service_stat.stat.exists" when: "matrix_beeper_linkedin_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-beeper-linkedin.service removal - name: Ensure systemd reloaded after matrix-beeper-linkedin.service removal
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_beeper_linkedin_service_stat.stat.exists" when: "matrix_beeper_linkedin_service_stat.stat.exists"

View File

@ -1,7 +1,7 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"

View File

@ -101,11 +101,11 @@ matrix_go_skype_bridge_configuration_extension_yaml: |
# If you need something more special, you can take full control by # If you need something more special, you can take full control by
# completely redefining `matrix_go_skype_bridge_configuration_yaml`. # completely redefining `matrix_go_skype_bridge_configuration_yaml`.
matrix_go_skype_bridge_configuration_extension: "{{ matrix_go_skype_bridge_configuration_extension_yaml|from_yaml if matrix_go_skype_bridge_configuration_extension_yaml|from_yaml is mapping else {} }}" matrix_go_skype_bridge_configuration_extension: "{{ matrix_go_skype_bridge_configuration_extension_yaml | from_yaml if matrix_go_skype_bridge_configuration_extension_yaml | from_yaml is mapping else {} }}"
# Holds the final configuration (a combination of the default and its extension). # 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_go_skype_bridge_configuration_yaml`. # You most likely don't need to touch this variable. Instead, see `matrix_go_skype_bridge_configuration_yaml`.
matrix_go_skype_bridge_configuration: "{{ matrix_go_skype_bridge_configuration_yaml|from_yaml|combine(matrix_go_skype_bridge_configuration_extension, recursive=True) }}" matrix_go_skype_bridge_configuration: "{{ matrix_go_skype_bridge_configuration_yaml | from_yaml | combine(matrix_go_skype_bridge_configuration_extension, recursive=True) }}"
matrix_go_skype_bridge_registration_yaml: | matrix_go_skype_bridge_registration_yaml: |
id: skype id: skype
@ -117,13 +117,13 @@ matrix_go_skype_bridge_registration_yaml: |
rate_limited: false rate_limited: false
namespaces: namespaces:
users: users:
- regex: '^@skype-(.*):{{ matrix_go_skype_bridge_homeserver_domain|regex_escape }}$' - regex: '^@skype-(.*):{{ matrix_go_skype_bridge_homeserver_domain | regex_escape }}$'
exclusive: true exclusive: true
- exclusive: true - exclusive: true
regex: '^@{{ matrix_go_skype_bridge_appservice_bot_username|regex_escape }}:{{ matrix_go_skype_bridge_homeserver_domain|regex_escape }}$' regex: '^@{{ matrix_go_skype_bridge_appservice_bot_username | regex_escape }}:{{ matrix_go_skype_bridge_homeserver_domain | regex_escape }}$'
de.sorunome.msc2409.push_ephemeral: true de.sorunome.msc2409.push_ephemeral: true
matrix_go_skype_bridge_registration: "{{ matrix_go_skype_bridge_registration_yaml|from_yaml }}" matrix_go_skype_bridge_registration: "{{ matrix_go_skype_bridge_registration_yaml | from_yaml }}"
# Enable End-to-bridge encryption # Enable End-to-bridge encryption
matrix_go_skype_bridge_bridge_encryption_allow: false matrix_go_skype_bridge_bridge_encryption_allow: false

View File

@ -1,21 +1,21 @@
--- ---
- set_fact: - ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-go-skype-bridge.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-go-skype-bridge.service'] }}"
when: matrix_go_skype_bridge_enabled|bool when: matrix_go_skype_bridge_enabled | bool
# If the matrix-synapse role is not used, these variables may not exist. # 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: >
{{ {{
matrix_synapse_container_extra_arguments|default([]) matrix_synapse_container_extra_arguments | default([])
+ +
["--mount type=bind,src={{ matrix_go_skype_bridge_config_path }}/registration.yaml,dst=/matrix-go-skype-bridge-registration.yaml,ro"] ["--mount type=bind,src={{ matrix_go_skype_bridge_config_path }}/registration.yaml,dst=/matrix-go-skype-bridge-registration.yaml,ro"]
}} }}
matrix_synapse_app_service_config_files: > matrix_synapse_app_service_config_files: >
{{ {{
matrix_synapse_app_service_config_files|default([]) matrix_synapse_app_service_config_files | default([])
+ +
["/matrix-go-skype-bridge-registration.yaml"] ["/matrix-go-skype-bridge-registration.yaml"]
}} }}
when: matrix_go_skype_bridge_enabled|bool when: matrix_go_skype_bridge_enabled | bool

View File

@ -1,23 +1,23 @@
--- ---
- import_tasks: "{{ role_path }}/tasks/init.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always
- import_tasks: "{{ role_path }}/tasks/validate_config.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_go_skype_bridge_enabled|bool" when: "run_setup | bool and matrix_go_skype_bridge_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-go-skype-bridge - setup-go-skype-bridge
- import_tasks: "{{ role_path }}/tasks/setup_install.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_go_skype_bridge_enabled|bool" when: "run_setup | bool and matrix_go_skype_bridge_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-go-skype-bridge - setup-go-skype-bridge
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" - ansible.builtin.import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_go_skype_bridge_enabled|bool" when: "run_setup | bool and not matrix_go_skype_bridge_enabled | bool"
tags: tags:
- setup-all - setup-all
- setup-go-skype-bridge - setup-go-skype-bridge

View File

@ -3,41 +3,43 @@
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-go-skype-bridge role needs to execute before the matrix-synapse role. The matrix-bridge-go-skype-bridge role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed | default(False)"
- set_fact: - ansible.builtin.set_fact:
matrix_go_skype_bridge_requires_restart: false matrix_go_skype_bridge_requires_restart: false
- block: - block:
- name: Check if an SQLite database already exists - name: Check if an SQLite database already exists
stat: ansible.builtin.stat:
path: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}" path: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}"
register: matrix_go_skype_bridge_sqlite_database_path_local_stat_result register: matrix_go_skype_bridge_sqlite_database_path_local_stat_result
- block: - block:
- set_fact: - ansible.builtin.set_fact:
matrix_postgres_db_migration_request: matrix_postgres_db_migration_request:
src: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}" src: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}"
dst: "{{ matrix_go_skype_bridge_database_connection_string }}" dst: "{{ matrix_go_skype_bridge_database_connection_string }}"
caller: "{{ role_path|basename }}" caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_go_skype_bridge_database_engine' engine_variable_name: 'matrix_go_skype_bridge_database_engine'
engine_old: 'sqlite' engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-go-skype-bridge.service'] systemd_services_to_stop: ['matrix-go-skype-bridge.service']
pgloader_options: ['--with "quote identifiers"'] pgloader_options: ['--with "quote identifiers"']
- 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_go_skype_bridge_requires_restart: true matrix_go_skype_bridge_requires_restart: true
when: "matrix_go_skype_bridge_sqlite_database_path_local_stat_result.stat.exists|bool" when: "matrix_go_skype_bridge_sqlite_database_path_local_stat_result.stat.exists | bool"
when: "matrix_go_skype_bridge_database_engine == 'postgres'" when: "matrix_go_skype_bridge_database_engine == 'postgres'"
- name: Ensure Go Skype Bridge paths exists - name: Ensure Go Skype Bridge paths exists
file: ansible.builtin.file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -48,7 +50,7 @@
- {path: "{{ matrix_go_skype_bridge_config_path }}", when: true} - {path: "{{ matrix_go_skype_bridge_config_path }}", when: true}
- {path: "{{ matrix_go_skype_bridge_data_path }}", when: true} - {path: "{{ matrix_go_skype_bridge_data_path }}", when: true}
- {path: "{{ matrix_go_skype_bridge_docker_src_files_path }}", when: "{{ matrix_go_skype_bridge_container_image_self_build }}"} - {path: "{{ matrix_go_skype_bridge_docker_src_files_path }}", when: "{{ matrix_go_skype_bridge_container_image_self_build }}"}
when: item.when|bool when: item.when | bool
- name: Ensure Go Skype Bridge image is pulled - name: Ensure Go Skype Bridge image is pulled
docker_image: docker_image:
@ -63,7 +65,7 @@
until: result is not failed until: result is not failed
- name: Ensure Go Skype Bridge repository is present on self-build - name: Ensure Go Skype Bridge repository is present on self-build
git: ansible.builtin.git:
repo: "{{ matrix_go_skype_bridge_container_image_self_build_repo }}" repo: "{{ matrix_go_skype_bridge_container_image_self_build_repo }}"
dest: "{{ matrix_go_skype_bridge_docker_src_files_path }}" dest: "{{ matrix_go_skype_bridge_docker_src_files_path }}"
version: "{{ matrix_go_skype_bridge_container_image_self_build_branch }}" version: "{{ matrix_go_skype_bridge_container_image_self_build_branch }}"
@ -71,7 +73,7 @@
become: true become: true
become_user: "{{ matrix_user_username }}" become_user: "{{ matrix_user_username }}"
register: matrix_go_skype_bridge_git_pull_results register: matrix_go_skype_bridge_git_pull_results
when: "matrix_go_skype_bridge_container_image_self_build|bool" when: "matrix_go_skype_bridge_container_image_self_build | bool"
- name: Ensure Go Skype Bridge Docker image is built - name: Ensure Go Skype Bridge Docker image is built
docker_image: docker_image:
@ -83,20 +85,20 @@
dockerfile: Dockerfile dockerfile: Dockerfile
path: "{{ matrix_go_skype_bridge_docker_src_files_path }}" path: "{{ matrix_go_skype_bridge_docker_src_files_path }}"
pull: true pull: true
when: "matrix_go_skype_bridge_container_image_self_build|bool" when: "matrix_go_skype_bridge_container_image_self_build | bool"
- name: Check if an old database file exists - name: Check if an old database file exists
stat: ansible.builtin.stat:
path: "{{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db" path: "{{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db"
register: matrix_go_skype_bridge_stat_database register: matrix_go_skype_bridge_stat_database
- name: Check if an old matrix state file exists - name: Check if an old matrix state file exists
stat: ansible.builtin.stat:
path: "{{ matrix_go_skype_bridge_base_path }}/mx-state.json" path: "{{ matrix_go_skype_bridge_base_path }}/mx-state.json"
register: matrix_go_skype_bridge_stat_mx_state register: matrix_go_skype_bridge_stat_mx_state
- name: (Data relocation) Ensure matrix-go-skype-bridge.service is stopped - name: (Data relocation) Ensure matrix-go-skype-bridge.service is stopped
service: ansible.builtin.service:
name: matrix-go-skype-bridge name: matrix-go-skype-bridge
state: stopped state: stopped
enabled: false enabled: false
@ -105,43 +107,43 @@
when: "matrix_go_skype_bridge_stat_database.stat.exists" when: "matrix_go_skype_bridge_stat_database.stat.exists"
- name: (Data relocation) Move go-skype-bridge database file to ./data directory - name: (Data relocation) Move go-skype-bridge database file to ./data directory
command: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db" ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db"
when: "matrix_go_skype_bridge_stat_database.stat.exists" when: "matrix_go_skype_bridge_stat_database.stat.exists"
- name: (Data relocation) Move go-skype-bridge mx-state file to ./data directory - name: (Data relocation) Move go-skype-bridge mx-state file to ./data directory
command: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json" ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json"
when: "matrix_go_skype_bridge_stat_mx_state.stat.exists" when: "matrix_go_skype_bridge_stat_mx_state.stat.exists"
- name: Ensure go-skype-bridge config.yaml installed - name: Ensure go-skype-bridge config.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_go_skype_bridge_configuration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_go_skype_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_go_skype_bridge_config_path }}/config.yaml" dest: "{{ matrix_go_skype_bridge_config_path }}/config.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure go-skype-bridge registration.yaml installed - name: Ensure go-skype-bridge registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_go_skype_bridge_registration|to_nice_yaml(indent=2, width=999999) }}" content: "{{ matrix_go_skype_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
dest: "{{ matrix_go_skype_bridge_config_path }}/registration.yaml" dest: "{{ matrix_go_skype_bridge_config_path }}/registration.yaml"
mode: 0644 mode: 0644
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-go-skype-bridge.service installed - name: Ensure matrix-go-skype-bridge.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-go-skype-bridge.service.j2" src: "{{ role_path }}/templates/systemd/matrix-go-skype-bridge.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-go-skype-bridge.service" dest: "{{ matrix_systemd_path }}/matrix-go-skype-bridge.service"
mode: 0644 mode: 0644
register: matrix_go_skype_bridge_systemd_service_result register: matrix_go_skype_bridge_systemd_service_result
- name: Ensure systemd reloaded after matrix-go-skype-bridge.service installation - name: Ensure systemd reloaded after matrix-go-skype-bridge.service installation
service: ansible.builtin.service:
daemon_reload: true daemon_reload: true
when: "matrix_go_skype_bridge_systemd_service_result.changed" when: "matrix_go_skype_bridge_systemd_service_result.changed"
- name: Ensure matrix-go-skype-bridge.service restarted, if necessary - name: Ensure matrix-go-skype-bridge.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-go-skype-bridge.service" name: "matrix-go-skype-bridge.service"
state: restarted state: restarted
when: "matrix_go_skype_bridge_requires_restart|bool" when: "matrix_go_skype_bridge_requires_restart | bool"

Some files were not shown because too many files have changed in this diff Show More