Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

88 строки
3.7 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. # Some components need to inspect an existing management room before they can start.
  53. # This optional static fixture does not attempt to model subsequent state changes.
  54. - --env=STUB_ROOM_STATE={{ (molecule_shared_stub_room_state | default([])) | to_json }}
  55. # Set molecule_shared_stub_verbose to "1" to log every request the stub is asked for.
  56. # How you find out why a component will not start, and for a component with no port of
  57. # its own, the only place to observe it acting on what the role configured.
  58. - --env=STUB_VERBOSE={{ molecule_shared_stub_verbose | default('') }}
  59. - --volume=/root/molecule-homeserver-stub.py:/stub.py:ro
  60. - "{{ molecule_shared_image_python }}"
  61. - python3
  62. - /stub.py
  63. register: molecule_shared_stub_start
  64. changed_when: molecule_shared_stub_start.rc == 0
  65. - name: Wait for the homeserver stub to answer
  66. ansible.builtin.command:
  67. argv:
  68. - docker
  69. - run
  70. - --rm
  71. - --network={{ molecule_shared_stub_network }}
  72. - "{{ molecule_shared_image_curl }}"
  73. - --silent
  74. - --fail
  75. - --max-time
  76. - "5"
  77. - "http://{{ molecule_shared_stub_hostname | default('matrix.molecule.local') }}:8008/_matrix/client/versions"
  78. register: molecule_shared_stub_ready
  79. changed_when: false
  80. until: molecule_shared_stub_ready.rc == 0
  81. retries: 12
  82. delay: 5