Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

89 lines
3.3 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Prepare Postmoogle Molecule tests
  6. hosts: all
  7. become: true
  8. vars_files:
  9. - "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
  10. - "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
  11. gather_facts: true
  12. tasks:
  13. - name: Ensure apt cache is updated
  14. ansible.builtin.apt:
  15. update_cache: true
  16. cache_valid_time: 600
  17. when: ansible_os_family == 'Debian'
  18. - name: Ensure required packages are installed
  19. ansible.builtin.package:
  20. name:
  21. - python3-requests
  22. - fuse-overlayfs
  23. state: present
  24. - name: Ensure Docker is installed
  25. ansible.builtin.include_role:
  26. name: ansible-role-docker
  27. vars:
  28. docker_daemon_options:
  29. storage-driver: fuse-overlayfs
  30. - name: Ensure the matrix group exists
  31. ansible.builtin.group:
  32. name: "{{ matrix_group_name }}"
  33. gid: "{{ matrix_user_gid }}"
  34. state: present
  35. - name: Ensure the matrix user exists
  36. ansible.builtin.user:
  37. name: "{{ matrix_user_name }}"
  38. uid: "{{ matrix_user_uid }}"
  39. group: "{{ matrix_group_name }}"
  40. create_home: false
  41. system: true
  42. state: present
  43. - name: Ensure the base data path exists
  44. ansible.builtin.file:
  45. path: "{{ matrix_base_data_path }}"
  46. state: directory
  47. owner: "{{ matrix_user_name }}"
  48. group: "{{ matrix_group_name }}"
  49. mode: "0750"
  50. - name: Ensure the container network the role attaches to exists
  51. ansible.builtin.command:
  52. argv:
  53. - docker
  54. - network
  55. - create
  56. - "{{ matrix_bridge_postmoogle_container_network }}"
  57. register: matrix_bridge_postmoogle_molecule_network
  58. changed_when: matrix_bridge_postmoogle_molecule_network.rc == 0
  59. failed_when:
  60. - matrix_bridge_postmoogle_molecule_network.rc != 0
  61. - "'already exists' not in matrix_bridge_postmoogle_molecule_network.stderr"
  62. - name: Ensure Postgres is running
  63. ansible.builtin.include_tasks:
  64. file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/postgres.yml"
  65. vars:
  66. molecule_shared_postgres_network: "{{ matrix_bridge_postmoogle_container_network }}"
  67. molecule_shared_postgres_database: "{{ matrix_bridge_postmoogle_database_name }}"
  68. molecule_shared_postgres_username: "{{ matrix_bridge_postmoogle_database_username }}"
  69. molecule_shared_postgres_password: "{{ matrix_bridge_postmoogle_database_password }}"
  70. - name: Ensure the homeserver stub is running
  71. ansible.builtin.include_tasks:
  72. file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/homeserver-stub.yml"
  73. vars:
  74. molecule_shared_stub_network: "{{ matrix_bridge_postmoogle_container_network }}"
  75. molecule_shared_stub_server_name: molecule.local
  76. molecule_shared_stub_user_id: "@{{ matrix_bridge_postmoogle_login }}:molecule.local"
  77. # Its request log is useful here because Postmoogle has no Matrix-facing HTTP
  78. # endpoint of its own. It proves that startup crossed the Matrix login boundary.
  79. molecule_shared_stub_verbose: "1"