mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-09-17 13:20:12 +00:00
Components here contact a homeserver while starting up and exit if it is
unreachable, so nearly every scenario will need one. Standing up a real
Synapse per role would dominate the run and drag in Postgres, and these
scenarios are not testing Synapse.
The stub answers the handful of endpoints components touch during startup
with the blandest plausible response, and is deliberately permissive: an
unrecognised path returns {} rather than 404, because the goal is to get the
component past its startup checks. It is not an authentication check or a
room state machine, and a scenario should not assert *about* it - if one
starts needing it to behave like a real homeserver, that scenario has
outgrown what these tests are for.
matrix-alertmanager-receiver now includes it instead of carrying its own
inline copy. Verified green afterwards.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
82 lines
3.0 KiB
YAML
82 lines
3.0 KiB
YAML
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
- name: Prepare matrix-alertmanager-receiver Molecule tests
|
|
hosts: all
|
|
become: true
|
|
vars_files:
|
|
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.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 before it runs. In a
|
|
# real deployment `matrix-base` creates them.
|
|
- 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_alertmanager_receiver_container_network }}"
|
|
register: matrix_alertmanager_receiver_molecule_network
|
|
changed_when: matrix_alertmanager_receiver_molecule_network.rc == 0
|
|
failed_when:
|
|
- matrix_alertmanager_receiver_molecule_network.rc != 0
|
|
- "'already exists' not in matrix_alertmanager_receiver_molecule_network.stderr"
|
|
|
|
# matrix-alertmanager-receiver contacts the homeserver while starting up -
|
|
# it fetches /_matrix/client/v3/joined_rooms to resolve its room mapping and
|
|
# exits 1 if that fails - so a homeserver has to exist for it to come up at
|
|
# all. The shared stub is enough; 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_alertmanager_receiver_container_network }}"
|
|
molecule_shared_stub_joined_rooms: "{{ matrix_alertmanager_receiver_config_matrix_room_mapping.values() | list }}"
|