mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-07-17 15:26:41 +00:00
Rename matrix_appservice_discord_* variables to matrix_bridge_appservice_discord_*
Part of adopting a uniform naming policy for bridge variables, where the variable prefix matches the role directory name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,15 +12,15 @@
|
||||
- install-all
|
||||
- install-appservice-discord
|
||||
block:
|
||||
- when: matrix_appservice_discord_enabled | bool
|
||||
- when: matrix_bridge_appservice_discord_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
|
||||
- when: matrix_appservice_discord_enabled | bool
|
||||
- when: matrix_bridge_appservice_discord_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-appservice-discord
|
||||
block:
|
||||
- when: not matrix_appservice_discord_enabled | bool
|
||||
- when: not matrix_bridge_appservice_discord_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
|
||||
@@ -14,40 +14,40 @@
|
||||
---
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_discord_migration_requires_restart: false
|
||||
matrix_bridge_appservice_discord_migration_requires_restart: false
|
||||
|
||||
- when: "matrix_appservice_discord_database_engine == 'postgres'"
|
||||
- when: "matrix_bridge_appservice_discord_database_engine == 'postgres'"
|
||||
block:
|
||||
- name: Check if an SQLite database already exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||
register: matrix_appservice_discord_sqlite_database_path_local_stat_result
|
||||
path: "{{ matrix_bridge_appservice_discord_sqlite_database_path_local }}"
|
||||
register: matrix_bridge_appservice_discord_sqlite_database_path_local_stat_result
|
||||
|
||||
- when: "matrix_appservice_discord_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
- when: "matrix_bridge_appservice_discord_sqlite_database_path_local_stat_result.stat.exists | bool"
|
||||
block:
|
||||
- ansible.builtin.include_role:
|
||||
name: galaxy/postgres
|
||||
tasks_from: migrate_db_to_postgres
|
||||
vars:
|
||||
postgres_db_migration_request:
|
||||
src: "{{ matrix_appservice_discord_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_appservice_discord_database_connString }}"
|
||||
src: "{{ matrix_bridge_appservice_discord_sqlite_database_path_local }}"
|
||||
dst: "{{ matrix_bridge_appservice_discord_database_connString }}"
|
||||
caller: "{{ role_path | basename }}"
|
||||
engine_variable_name: 'matrix_appservice_discord_database_engine'
|
||||
engine_variable_name: 'matrix_bridge_appservice_discord_database_engine'
|
||||
engine_old: 'sqlite'
|
||||
systemd_services_to_stop: ['matrix-appservice-discord.service']
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_appservice_discord_migration_requires_restart: true
|
||||
matrix_bridge_appservice_discord_migration_requires_restart: true
|
||||
|
||||
- name: Ensure Appservice Discord image is pulled
|
||||
community.docker.docker_image_pull:
|
||||
name: "{{ matrix_appservice_discord_container_image }}"
|
||||
name: "{{ matrix_bridge_appservice_discord_container_image }}"
|
||||
pull: always
|
||||
register: matrix_appservice_discord_container_image_pull_result
|
||||
register: matrix_bridge_appservice_discord_container_image_pull_result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: matrix_appservice_discord_container_image_pull_result is not failed
|
||||
until: matrix_bridge_appservice_discord_container_image_pull_result is not failed
|
||||
|
||||
- name: Ensure AppService Discord paths exist
|
||||
ansible.builtin.file:
|
||||
@@ -57,14 +57,14 @@
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
with_items:
|
||||
- "{{ matrix_appservice_discord_base_path }}"
|
||||
- "{{ matrix_appservice_discord_config_path }}"
|
||||
- "{{ matrix_appservice_discord_data_path }}"
|
||||
- "{{ matrix_bridge_appservice_discord_base_path }}"
|
||||
- "{{ matrix_bridge_appservice_discord_config_path }}"
|
||||
- "{{ matrix_bridge_appservice_discord_data_path }}"
|
||||
|
||||
- name: Check if an old database file already exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_appservice_discord_base_path }}/discord.db"
|
||||
register: matrix_appservice_discord_stat_db
|
||||
path: "{{ matrix_bridge_appservice_discord_base_path }}/discord.db"
|
||||
register: matrix_bridge_appservice_discord_stat_db
|
||||
|
||||
- name: (Data relocation) Ensure matrix-appservice-discord.service is stopped
|
||||
ansible.builtin.service:
|
||||
@@ -73,55 +73,55 @@
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
failed_when: false
|
||||
when: "matrix_appservice_discord_stat_db.stat.exists"
|
||||
when: "matrix_bridge_appservice_discord_stat_db.stat.exists"
|
||||
|
||||
- name: (Data relocation) Move AppService Discord discord.db file to ./data directory
|
||||
ansible.builtin.command:
|
||||
cmd: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}"
|
||||
creates: "{{ matrix_appservice_discord_data_path }}/{{ item }}"
|
||||
removes: "{{ matrix_appservice_discord_base_path }}/{{ item }}"
|
||||
cmd: "mv {{ matrix_bridge_appservice_discord_base_path }}/{{ item }} {{ matrix_bridge_appservice_discord_data_path }}/{{ item }}"
|
||||
creates: "{{ matrix_bridge_appservice_discord_data_path }}/{{ item }}"
|
||||
removes: "{{ matrix_bridge_appservice_discord_base_path }}/{{ item }}"
|
||||
with_items:
|
||||
- discord.db
|
||||
- user-store.db
|
||||
- room-store.db
|
||||
when: "matrix_appservice_discord_stat_db.stat.exists"
|
||||
when: "matrix_bridge_appservice_discord_stat_db.stat.exists"
|
||||
|
||||
- name: Ensure AppService Discord config.yaml installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_discord_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_discord_config_path }}/config.yaml"
|
||||
content: "{{ matrix_bridge_appservice_discord_configuration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_bridge_appservice_discord_config_path }}/config.yaml"
|
||||
mode: '0644'
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
register: matrix_appservice_discord_config_result
|
||||
register: matrix_bridge_appservice_discord_config_result
|
||||
|
||||
- name: Ensure AppService Discord registration.yaml installed
|
||||
ansible.builtin.copy:
|
||||
content: "{{ matrix_appservice_discord_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml"
|
||||
content: "{{ matrix_bridge_appservice_discord_registration | to_nice_yaml(indent=2, width=999999) }}"
|
||||
dest: "{{ matrix_bridge_appservice_discord_config_path }}/registration.yaml"
|
||||
mode: '0644'
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
register: matrix_appservice_discord_registration_result
|
||||
register: matrix_bridge_appservice_discord_registration_result
|
||||
|
||||
# If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated.
|
||||
# If `matrix_bridge_appservice_discord_client_id` hasn't changed, the same invite link would be generated.
|
||||
# We intentionally suppress Ansible changes.
|
||||
- name: Generate AppService Discord invite link
|
||||
ansible.builtin.shell: >-
|
||||
{{ devture_systemd_docker_base_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
|
||||
--cap-drop=ALL
|
||||
--mount type=bind,src={{ matrix_appservice_discord_config_path }},dst=/cfg
|
||||
--mount type=bind,src={{ matrix_bridge_appservice_discord_config_path }},dst=/cfg
|
||||
-w /cfg
|
||||
{{ matrix_appservice_discord_container_image }}
|
||||
{{ matrix_bridge_appservice_discord_container_image }}
|
||||
/bin/sh -c "node /build/tools/addbot.js > /cfg/invite_link"
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure matrix-appservice-discord container network is created
|
||||
when: matrix_appservice_discord_container_network != 'host'
|
||||
when: matrix_bridge_appservice_discord_container_network != 'host'
|
||||
community.general.docker_network:
|
||||
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
|
||||
name: "{{ matrix_appservice_discord_container_network }}"
|
||||
name: "{{ matrix_bridge_appservice_discord_container_network }}"
|
||||
driver: bridge
|
||||
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
|
||||
|
||||
@@ -130,17 +130,17 @@
|
||||
src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-appservice-discord.service"
|
||||
mode: '0644'
|
||||
register: matrix_appservice_discord_systemd_service_result
|
||||
register: matrix_bridge_appservice_discord_systemd_service_result
|
||||
|
||||
- name: Determine whether matrix-appservice-discord needs a restart
|
||||
ansible.builtin.set_fact:
|
||||
matrix_appservice_discord_restart_necessary: >-
|
||||
matrix_bridge_appservice_discord_restart_necessary: >-
|
||||
{{
|
||||
matrix_appservice_discord_migration_requires_restart | default(false)
|
||||
or matrix_appservice_discord_config_result.changed | default(false)
|
||||
or matrix_appservice_discord_registration_result.changed | default(false)
|
||||
or matrix_appservice_discord_systemd_service_result.changed | default(false)
|
||||
or matrix_appservice_discord_container_image_pull_result.changed | default(false)
|
||||
matrix_bridge_appservice_discord_migration_requires_restart | default(false)
|
||||
or matrix_bridge_appservice_discord_config_result.changed | default(false)
|
||||
or matrix_bridge_appservice_discord_registration_result.changed | default(false)
|
||||
or matrix_bridge_appservice_discord_systemd_service_result.changed | default(false)
|
||||
or matrix_bridge_appservice_discord_container_image_pull_result.changed | default(false)
|
||||
}}
|
||||
|
||||
- name: Ensure matrix-appservice-discord.service restarted, if necessary
|
||||
@@ -148,4 +148,4 @@
|
||||
name: "matrix-appservice-discord.service"
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
when: "matrix_appservice_discord_migration_requires_restart | bool"
|
||||
when: "matrix_bridge_appservice_discord_migration_requires_restart | bool"
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
- name: Check existence of matrix-appservice-discord service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-appservice-discord.service"
|
||||
register: matrix_appservice_discord_service_stat
|
||||
register: matrix_bridge_appservice_discord_service_stat
|
||||
|
||||
- when: matrix_appservice_discord_service_stat.stat.exists | bool
|
||||
- when: matrix_bridge_appservice_discord_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure matrix-appservice-discord is stopped
|
||||
ansible.builtin.service:
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml).
|
||||
when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0"
|
||||
with_items:
|
||||
- {'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_image_name_prefix', 'new': 'matrix_appservice_discord_container_image_registry_prefix'}
|
||||
- {'old': 'matrix_appservice_discord_docker_image', 'new': 'matrix_appservice_discord_container_image'}
|
||||
- {'old': 'matrix_appservice_discord_docker_image_force_pull', 'new': 'matrix_appservice_discord_container_image_force_pull'}
|
||||
- {'old': 'matrix_appservice_discord_docker_image_registry_prefix', 'new': 'matrix_appservice_discord_container_image_registry_prefix'}
|
||||
- {'old': 'matrix_appservice_discord_docker_image_registry_prefix_upstream', 'new': 'matrix_appservice_discord_container_image_registry_prefix_upstream'}
|
||||
- {'old': 'matrix_appservice_discord_docker_image_registry_prefix_upstream_default', 'new': 'matrix_appservice_discord_container_image_registry_prefix_upstream_default'}
|
||||
- {'old': 'matrix_appservice_discord_container_image_force_pull', 'new': '<removed> (the new community.docker.docker_image_pull module handles this natively)'}
|
||||
- {'old': 'matrix_appservice_discord_container_image_self_build', 'new': '<removed> (self-building was never actually implemented for this role, so enabling it only led to image pull failures; the prebuilt image is amd64-only, so on other architectures consider the mautrix-discord bridge instead)'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_container_expose_client_server_api_port', 'new': '<superseded by matrix_bridge_appservice_discord_container_http_host_bind_port>'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_container_image_name_prefix', 'new': 'matrix_bridge_appservice_discord_container_image_registry_prefix'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_docker_image', 'new': 'matrix_bridge_appservice_discord_container_image'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_docker_image_force_pull', 'new': 'matrix_bridge_appservice_discord_container_image_force_pull'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_docker_image_registry_prefix', 'new': 'matrix_bridge_appservice_discord_container_image_registry_prefix'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_docker_image_registry_prefix_upstream', 'new': 'matrix_bridge_appservice_discord_container_image_registry_prefix_upstream'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_docker_image_registry_prefix_upstream_default', 'new': 'matrix_bridge_appservice_discord_container_image_registry_prefix_upstream_default'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_container_image_force_pull', 'new': '<removed> (the new community.docker.docker_image_pull module handles this natively)'}
|
||||
- {'old': 'matrix_bridge_appservice_discord_container_image_self_build', 'new': '<removed> (self-building was never actually implemented for this role, so enabling it only led to image pull failures; the prebuilt image is amd64-only, so on other architectures consider the mautrix-discord bridge instead)'}
|
||||
|
||||
- name: Fail if required appservice-discord settings not defined
|
||||
ansible.builtin.fail:
|
||||
@@ -28,15 +28,15 @@
|
||||
You need to define a required configuration setting (`{{ item.name }}`).
|
||||
when: "item.when | bool and lookup('vars', item.name, default='') | string | length == 0"
|
||||
with_items:
|
||||
- {'name': 'matrix_appservice_discord_client_id', when: true}
|
||||
- {'name': 'matrix_appservice_discord_bot_token', when: true}
|
||||
- {'name': 'matrix_appservice_discord_appservice_token', when: true}
|
||||
- {'name': 'matrix_appservice_discord_homeserver_token', when: true}
|
||||
- {'name': 'matrix_appservice_discord_homeserver_domain', when: true}
|
||||
- {'name': 'matrix_appservice_discord_container_network', when: true}
|
||||
- {'name': 'matrix_appservice_discord_database_hostname', when: "{{ matrix_appservice_discord_database_engine == 'postgres' }}"}
|
||||
- {'name': 'matrix_bridge_appservice_discord_client_id', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_bot_token', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_appservice_token', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_homeserver_token', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_homeserver_domain', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_container_network', when: true}
|
||||
- {'name': 'matrix_bridge_appservice_discord_database_hostname', when: "{{ matrix_bridge_appservice_discord_database_engine == 'postgres' }}"}
|
||||
|
||||
- name: Require a valid database engine
|
||||
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']"
|
||||
msg: "`matrix_bridge_appservice_discord_database_engine` needs to be either 'sqlite' or 'postgres'"
|
||||
when: "matrix_bridge_appservice_discord_database_engine not in ['sqlite', 'postgres']"
|
||||
|
||||
Reference in New Issue
Block a user