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.
 
 
 

87 rivejä
3.4 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Prepare mautrix-meta-messenger 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. # The role's file tasks set owner/group by name and Ansible resolves those
  31. # through the passwd database, so they have to exist first. matrix-base
  32. # creates them in a real deployment.
  33. - name: Ensure the matrix group exists
  34. ansible.builtin.group:
  35. name: "{{ matrix_group_name }}"
  36. gid: "{{ matrix_user_gid }}"
  37. state: present
  38. - name: Ensure the matrix user exists
  39. ansible.builtin.user:
  40. name: "{{ matrix_user_name }}"
  41. uid: "{{ matrix_user_uid }}"
  42. group: "{{ matrix_group_name }}"
  43. create_home: false
  44. system: true
  45. state: present
  46. - name: Ensure the base data path exists
  47. ansible.builtin.file:
  48. path: "{{ matrix_base_data_path }}"
  49. state: directory
  50. owner: "{{ matrix_user_name }}"
  51. group: "{{ matrix_group_name }}"
  52. mode: "0750"
  53. # The role creates this network itself during converge, but the homeserver
  54. # stub below has to be attached to it before that, so it is created here.
  55. - name: Ensure the container network the role attaches to exists
  56. ansible.builtin.command:
  57. argv:
  58. - docker
  59. - network
  60. - create
  61. - "{{ matrix_bridge_mautrix_meta_messenger_container_network }}"
  62. register: mautrix_meta_messenger_molecule_network
  63. changed_when: mautrix_meta_messenger_molecule_network.rc == 0
  64. failed_when:
  65. - mautrix_meta_messenger_molecule_network.rc != 0
  66. - "'already exists' not in mautrix_meta_messenger_molecule_network.stderr"
  67. # The bridge contacts the homeserver as it starts, and calls /whoami before
  68. # it will run at all - it exits if the id it gets back is not the bot user
  69. # it was configured as. It is not being asked to bridge anything; there is
  70. # no Meta account anywhere in this scenario and there is deliberately never
  71. # going to be one. See molecule-shared/homeserver-stub.py.
  72. - name: Ensure the homeserver stub is running
  73. ansible.builtin.include_tasks:
  74. file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/homeserver-stub.yml"
  75. vars:
  76. molecule_shared_stub_network: "{{ matrix_bridge_mautrix_meta_messenger_container_network }}"
  77. molecule_shared_stub_server_name: "{{ matrix_bridge_mautrix_meta_messenger_homeserver_domain }}"
  78. molecule_shared_stub_user_id: "@{{ matrix_bridge_mautrix_meta_messenger_appservice_username }}:{{ matrix_bridge_mautrix_meta_messenger_homeserver_domain }}"