mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-08-30 20:43:13 +00:00
`group_vars/matrix_servers` selects postgres whenever postgres is enabled, which is the default, so postgres is what essentially every deployment runs. The scenarios were testing sqlite - a path almost nobody is on. How little that path is used is not a guess: the mautrix-meta bridges could not start at all under sqlite, and nobody reported it. Testing the engine users are actually on is worth more than keeping coverage of the one they are not, so no scenario is left behind on sqlite. Four of the eight scenarios have a database and are converted; the other four have none and are untouched. molecule-shared/tasks/postgres.yml stands Postgres up on the scenario's network, with the data directory on a tmpfs since it is thrown away with the container. The image is pinned at the major the postgres role deploys to new installations and left to Renovate: when a new major lands, the PR bumping that pin runs every scenario against it, which is the earliest warning we get that a component does not cope. Each scenario gives its database and user names that differ from the role's defaults, so the component reaching the database proves the role built its connection string out of them. The assertions moved from "a file appeared at the path we configured" to "these tables exist", which is strictly stronger: tables can only appear once the component has resolved the hostname, authenticated with the credentials the role rendered, and run its migrations to completion. Costs about 10 seconds per affected scenario (115s to 125s locally for mautrix-whatsapp), on jobs that run in parallel. Gotcha worth recording: since Postgres 18 the image puts PGDATA in a versioned subdirectory and refuses to start if it finds a mount at the old /var/lib/postgresql/data, so the tmpfs is mounted at /var/lib/postgresql. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SEH3vxYSQ5SV4N5z61eyGT
92 lines
3.7 KiB
YAML
92 lines
3.7 KiB
YAML
# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
---
|
|
- name: Prepare matrix-reminder-bot 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, which Ansible resolves through the
|
|
# passwd database, so they have to exist first. `matrix-base` creates them for real.
|
|
- 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"
|
|
|
|
# The role creates this network itself during converge, but the stub has to be on it
|
|
# before the bot starts.
|
|
- name: Ensure the container network the role attaches to exists
|
|
ansible.builtin.command:
|
|
argv:
|
|
- docker
|
|
- network
|
|
- create
|
|
- "{{ matrix_bot_matrix_reminder_bot_container_network }}"
|
|
register: matrix_bot_matrix_reminder_bot_molecule_network
|
|
changed_when: matrix_bot_matrix_reminder_bot_molecule_network.rc == 0
|
|
failed_when:
|
|
- matrix_bot_matrix_reminder_bot_molecule_network.rc != 0
|
|
- "'already exists' not in matrix_bot_matrix_reminder_bot_molecule_network.stderr"
|
|
|
|
# Not an appservice: it logs in with the username and password the role rendered, retrying
|
|
# every 15 seconds until that succeeds. The stub answers with an access token, which is
|
|
# enough to reach the sync loop. Nothing is asserted about the stub itself.
|
|
- name: Ensure Postgres is running
|
|
ansible.builtin.include_tasks:
|
|
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/postgres.yml"
|
|
vars:
|
|
molecule_shared_postgres_network: "{{ matrix_bot_matrix_reminder_bot_container_network }}"
|
|
molecule_shared_postgres_database: "{{ matrix_bot_matrix_reminder_bot_database_name }}"
|
|
molecule_shared_postgres_username: "{{ matrix_bot_matrix_reminder_bot_database_username }}"
|
|
molecule_shared_postgres_password: "{{ matrix_bot_matrix_reminder_bot_database_password }}"
|
|
|
|
- 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_bot_matrix_reminder_bot_container_network }}"
|
|
molecule_shared_stub_user_id: "@{{ matrix_bot_matrix_reminder_bot_matrix_user_id_localpart }}:{{ matrix_domain }}"
|