Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

85 řádky
3.4 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. # Stands up a stand-in homeserver on a container network, for scenarios whose component
  6. # contacts a homeserver while starting up.
  7. #
  8. # Include from a scenario's prepare.yml:
  9. #
  10. # - name: Ensure the homeserver stub is running
  11. # ansible.builtin.include_tasks:
  12. # file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/tasks/homeserver-stub.yml"
  13. # vars:
  14. # molecule_shared_stub_network: "{{ <role>_container_network }}"
  15. # molecule_shared_stub_joined_rooms: ["!some-room:molecule.local"]
  16. #
  17. # The component should then be pointed at http://matrix.molecule.local:8008.
  18. #
  19. # See molecule-shared/homeserver-stub.py for what it answers and, more importantly, what it is not.
  20. - name: Ensure the homeserver stub script is present
  21. ansible.builtin.copy:
  22. src: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/homeserver-stub.py"
  23. dest: /root/molecule-homeserver-stub.py
  24. mode: "0755"
  25. - name: Ensure a previous homeserver stub is gone
  26. ansible.builtin.command:
  27. argv:
  28. - docker
  29. - rm
  30. - --force
  31. - "{{ molecule_shared_stub_name | default('matrix-homeserver-stub') }}"
  32. register: molecule_shared_stub_removal
  33. changed_when: molecule_shared_stub_removal.rc == 0
  34. failed_when: false
  35. # The alias is what the component resolves, so its configuration can name a hostname
  36. # rather than a container name.
  37. - name: Ensure the homeserver stub is running
  38. ansible.builtin.command:
  39. argv:
  40. - docker
  41. - run
  42. - --detach
  43. - --name={{ molecule_shared_stub_name | default('matrix-homeserver-stub') }}
  44. - --network={{ molecule_shared_stub_network }}
  45. - --network-alias={{ molecule_shared_stub_hostname | default('matrix.molecule.local') }}
  46. - --env=STUB_SERVER_NAME={{ molecule_shared_stub_server_name | default('molecule.local') }}
  47. - --env=STUB_JOINED_ROOMS={{ (molecule_shared_stub_joined_rooms | default([])) | join(',') }}
  48. # Appservices call /whoami on startup and refuse to run if the id returned is not
  49. # the bot user they were configured as, so a scenario bridging anything has to tell
  50. # the stub who it should claim to be.
  51. - --env=STUB_USER_ID={{ molecule_shared_stub_user_id | default('@stub:' + (molecule_shared_stub_server_name | default('molecule.local'))) }}
  52. # Set molecule_shared_stub_verbose to "1" to log every request the stub is asked for.
  53. # How you find out why a component will not start, and for a component with no port of
  54. # its own, the only place to observe it acting on what the role configured.
  55. - --env=STUB_VERBOSE={{ molecule_shared_stub_verbose | default('') }}
  56. - --volume=/root/molecule-homeserver-stub.py:/stub.py:ro
  57. - "{{ molecule_shared_image_python }}"
  58. - python3
  59. - /stub.py
  60. register: molecule_shared_stub_start
  61. changed_when: molecule_shared_stub_start.rc == 0
  62. - name: Wait for the homeserver stub to answer
  63. ansible.builtin.command:
  64. argv:
  65. - docker
  66. - run
  67. - --rm
  68. - --network={{ molecule_shared_stub_network }}
  69. - "{{ molecule_shared_image_curl }}"
  70. - --silent
  71. - --fail
  72. - --max-time
  73. - "5"
  74. - "http://{{ molecule_shared_stub_hostname | default('matrix.molecule.local') }}:8008/_matrix/client/versions"
  75. register: molecule_shared_stub_ready
  76. changed_when: false
  77. until: molecule_shared_stub_ready.rc == 0
  78. retries: 12
  79. delay: 5