mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-09-02 05:53:14 +00:00
Proves the bridge starts on the configuration this role rendered: the systemd unit is active and has not been restarting, the appservice port is open, config.yaml and registration.yaml (parsed, not grepped) carry the scenario's homeserver address, bot username, tokens, command prefix, avatar-proxy key, public address and log level, the sqlite database was created under the role's data path as the role's uid, and the running container is the version defaults/main.yml pins. It does not bridge anything. Discord is behind an account, which is where a scenario stops being a test of this repository. Two things are specific to this role rather than copied from the mautrix-whatsapp scenario: - mautrix-discord is the only bridge here whose validate_config.yml requires a public address. It is composed from hostname + scheme + path prefix, and those same three feed the Traefik avatar-proxy labels, so the scenario picks a non-`/` path prefix and a non-default scheme and asserts the composed router rule and strip-prefix middleware - both in the label file and, read back off the running container, as labels Docker accepted. Traefik labels are left enabled here for that reason, unlike in the mautrix-whatsapp scenario which asserts their absence. - matrix_bridge_mautrix_discord_bridge_double_puppet_server_map_default in the role's defaults references matrix_bridge_beeper_linkedin_homeserver_domain and matrix_bridge_beeper_linkedin_homeserver_address - variables belonging to a different role, evidently copy-pasted from matrix-bridge-beeper-linkedin, and unique to this role among the bridges. A playbook run has every role's defaults in scope so it resolves silently; a role scenario has only this role loaded and the template fails on the undefined name. The scenario neutralises it in its own group_vars rather than touching the role. Falsified the crash-loop assertion: pointing the in-container sqlite path at a directory that does not exist makes the bridge exit on startup, and the run then fails at "Assert the service is active and has not been restarting" with "activating after 5 automatic restart(s)". Reverted, and green again since - including idempotence.
83 lines
3.0 KiB
YAML
83 lines
3.0 KiB
YAML
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
- name: Prepare mautrix-discord Molecule tests
|
|
hosts: all
|
|
become: true
|
|
vars_files:
|
|
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
|
|
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
|
|
gather_facts: true
|
|
tasks:
|
|
- name: Ensure apt cache is updated
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
cache_valid_time: 600
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
- name: Ensure required packages are installed
|
|
ansible.builtin.package:
|
|
name:
|
|
- python3-requests
|
|
- fuse-overlayfs
|
|
state: present
|
|
|
|
- name: Ensure Docker is installed
|
|
ansible.builtin.include_role:
|
|
name: ansible-role-docker
|
|
vars:
|
|
docker_daemon_options:
|
|
storage-driver: fuse-overlayfs
|
|
|
|
# The role's file tasks set owner/group by name and Ansible resolves those
|
|
# through the passwd database, so they have to exist first. matrix-base
|
|
# creates them in a real deployment.
|
|
- name: Ensure the matrix group exists
|
|
ansible.builtin.group:
|
|
name: "{{ matrix_group_name }}"
|
|
gid: "{{ matrix_user_gid }}"
|
|
state: present
|
|
|
|
- name: Ensure the matrix user exists
|
|
ansible.builtin.user:
|
|
name: "{{ matrix_user_name }}"
|
|
uid: "{{ matrix_user_uid }}"
|
|
group: "{{ matrix_group_name }}"
|
|
create_home: false
|
|
system: true
|
|
state: present
|
|
|
|
- name: Ensure the base data path exists
|
|
ansible.builtin.file:
|
|
path: "{{ matrix_base_data_path }}"
|
|
state: directory
|
|
owner: "{{ matrix_user_name }}"
|
|
group: "{{ matrix_group_name }}"
|
|
mode: "0750"
|
|
|
|
- name: Ensure the container network the role attaches to exists
|
|
ansible.builtin.command:
|
|
argv:
|
|
- docker
|
|
- network
|
|
- create
|
|
- "{{ matrix_bridge_mautrix_discord_container_network }}"
|
|
register: mautrix_discord_molecule_network
|
|
changed_when: mautrix_discord_molecule_network.rc == 0
|
|
failed_when:
|
|
- mautrix_discord_molecule_network.rc != 0
|
|
- "'already exists' not in mautrix_discord_molecule_network.stderr"
|
|
|
|
# The bridge contacts the homeserver as it starts, and refuses to run if
|
|
# /whoami does not name the bot user it was configured as - see
|
|
# molecule-shared/homeserver-stub.py.
|
|
- name: Ensure the homeserver stub is running
|
|
ansible.builtin.include_tasks:
|
|
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/homeserver-stub.yml"
|
|
vars:
|
|
molecule_shared_stub_network: "{{ matrix_bridge_mautrix_discord_container_network }}"
|
|
molecule_shared_stub_server_name: molecule.local
|
|
molecule_shared_stub_user_id: "@{{ matrix_bridge_mautrix_discord_appservice_bot_username }}:{{ matrix_bridge_mautrix_discord_homeserver_domain }}"
|