Make changes according to feedback

Co-authored-by: Slavi Pantaleev <slavi@devture.com>

Update group_vars/matrix_servers

Co-authored-by: Slavi Pantaleev <slavi@devture.com>

Remove old data migration tasks

Co-authored-by: Slavi Pantaleev <slavi@devture.com>

Update roles/matrix-bridge-mautrix-discord/tasks/validate_config.yml

Co-authored-by: Slavi Pantaleev <slavi@devture.com>

Redo bridge permissions
This commit is contained in:
MdotAmaan 2022-07-28 22:14:45 +04:00 committed by MdotAmaan
parent 8621ff1379
commit 6fb961eb12
7 changed files with 19 additions and 52 deletions

View file

@ -1,5 +1,7 @@
# Setting up Mautrix Discord (optional)
**Note**: bridging to [Discord](https://discordapp.com/) can also happen via the [mx-puppet-discord](configuring-playbook-bridge-mx-puppet-discord.md) and [matrix-appservice-discord](configuring-playbook-bridge-appservice-discord.md) bridges supported by the playbook.
The playbook can install and configure [mautrix-discord](https://github.com/mautrix/discord) for you.
See the project's [documentation](https://docs.mau.fi/bridges/go/discord/index.html) to learn what it does and why it might be useful to you.

View file

@ -646,9 +646,9 @@ matrix_mautrix_discord_systemd_required_services_list: |
(['matrix-nginx-proxy.service'] if matrix_nginx_proxy_enabled else [])
}}
matrix_mautrix_discord_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'maudiscord.as.token') | to_uuid }}"
matrix_mautrix_discord_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'maudisc.as.tok') | to_uuid }}"
matrix_mautrix_discord_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'maudiscord.hs.token') | to_uuid }}"
matrix_mautrix_discord_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'maudisc.hs.tok') | to_uuid }}"
matrix_mautrix_discord_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}"

View file

@ -25,6 +25,12 @@ matrix_mautrix_discord_appservice_address: "http://matrix-mautrix-discord:8080"
matrix_mautrix_discord_command_prefix: "!discord"
matrix_mautrix_discord_bridge_permissions: |
{{
{matrix_mautrix_discord_homeserver_domain: 'user'}
| combine({matrix_admin: 'admin'} if matrix_admin else {})
}}
# A list of extra arguments to pass to the container
matrix_mautrix_discord_container_extra_arguments: []

View file

@ -87,33 +87,6 @@
pull: true
when: "matrix_mautrix_discord_container_image_self_build | bool"
- name: Check if an old database file exists
ansible.builtin.stat:
path: "{{ matrix_mautrix_discord_base_path }}/mautrix-discord.db"
register: matrix_mautrix_discord_stat_database
- name: Check if an old matrix state file exists
ansible.builtin.stat:
path: "{{ matrix_mautrix_discord_base_path }}/mx-state.json"
register: matrix_mautrix_discord_stat_mx_state
- name: (Data relocation) Ensure matrix-mautrix-discord.service is stopped
ansible.builtin.service:
name: matrix-mautrix-discord
state: stopped
enabled: false
daemon_reload: true
failed_when: false
when: "matrix_mautrix_discord_stat_database.stat.exists"
- name: (Data relocation) Move mautrix-discord database file to ./data directory
ansible.builtin.command: "mv {{ matrix_mautrix_discord_base_path }}/mautrix-discord.db {{ matrix_mautrix_discord_data_path }}/mautrix-discord.db"
when: "matrix_mautrix_discord_stat_database.stat.exists"
- name: (Data relocation) Move mautrix-discord mx-state file to ./data directory
ansible.builtin.command: "mv {{ matrix_mautrix_discord_base_path }}/mx-state.json {{ matrix_mautrix_discord_data_path }}/mx-state.json"
when: "matrix_mautrix_discord_stat_mx_state.stat.exists"
- name: Ensure mautrix-discord config.yaml installed
ansible.builtin.copy:
content: "{{ matrix_mautrix_discord_configuration | to_nice_yaml(indent=2, width=999999) }}"

View file

@ -8,13 +8,3 @@
with_items:
- "matrix_mautrix_discord_appservice_token"
- "matrix_mautrix_discord_homeserver_token"
- name: (Deprecation) Catch and report renamed settings
ansible.builtin.fail:
msg: >-
Your configuration contains a variable, which now has a different name.
Please change your configuration to rename the variable (`{{ item.old }}` -> `{{ item.new }}`).
when: "item.old in vars"
with_items:
- {'old': 'matrix_mautrix_discord_log_level', 'new': 'matrix_mautrix_discord_logging_level'}

View file

@ -2,9 +2,9 @@
# Homeserver details.
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: {{ matrix_mautrix_discord_homeserver_address }}
address: {{ matrix_mautrix_discord_homeserver_address | to_json }}
# The domain of the homeserver (for MXIDs, etc).
domain: {{ matrix_mautrix_discord_homeserver_domain }}
domain: {{ matrix_mautrix_discord_homeserver_domain | to_json }}
# Is the homeserver actually mautrix-asmux?
asmux: false
# The URL to push real-time bridge status to.
@ -20,7 +20,7 @@ homeserver:
# Changing these values requires regeneration of the registration.
appservice:
# The address that the homeserver can use to connect to this appservice.
address: {{ matrix_mautrix_discord_appservice_address }}
address: {{ matrix_mautrix_discord_appservice_address | to_json }}
# The hostname and port where this appservice should listen.
hostname: 0.0.0.0
@ -58,8 +58,8 @@ appservice:
ephemeral_events: true
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
as_token: "{{ matrix_mautrix_discord_appservice_token }}"
hs_token: "{{ matrix_mautrix_discord_homeserver_token }}"
as_token: {{ matrix_mautrix_discord_appservice_token | to_json }}
hs_token: {{ matrix_mautrix_discord_homeserver_token | to_json }}
# Bridge config
bridge:
@ -208,11 +208,7 @@ bridge:
# * - All Matrix users
# domain - All users on that homeserver
# mxid - Specific user
permissions:
"{{ matrix_mautrix_discord_homeserver_domain }}": user
{% if matrix_admin %}
"{{ matrix_admin }}": admin
{% endif %}
permissions: {{ matrix_mautrix_discord_bridge_permissions|to_json }}
logging:
directory: ./logs
@ -220,6 +216,6 @@ logging:
file_date_format: "2006-01-02"
file_mode: 384
timestamp_format: Jan _2, 2006 15:04:05
print_level: {{ matrix_mautrix_discord_logging_level }}
print_level: {{ matrix_mautrix_discord_logging_level | to_json }}
print_json: false
file_json: false

View file

@ -24,8 +24,8 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-mautrix-discor
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--network={{ matrix_docker_network }} \
-v {{ matrix_mautrix_discord_config_path }}:/config:z \
-v {{ matrix_mautrix_discord_data_path }}:/data:z \
--mount type=bind,src={{ matrix_mautrix_discord_config_path }},dst=/config,ro \
--mount type=bind,src={{ matrix_mautrix_discord_data_path }},dst=/data \
--workdir=/data \
{% for arg in matrix_mautrix_discord_container_extra_arguments %}
{{ arg }} \