Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

82 líneas
3.1 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
  6. # component 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
  20. # importantly, for what it is not.
  21. - name: Ensure the homeserver stub script is present
  22. ansible.builtin.copy:
  23. src: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/homeserver-stub.py"
  24. dest: /root/molecule-homeserver-stub.py
  25. mode: "0755"
  26. - name: Ensure a previous homeserver stub is gone
  27. ansible.builtin.command:
  28. argv:
  29. - docker
  30. - rm
  31. - --force
  32. - "{{ molecule_shared_stub_name | default('matrix-homeserver-stub') }}"
  33. register: molecule_shared_stub_removal
  34. changed_when: molecule_shared_stub_removal.rc == 0
  35. failed_when: false
  36. # The alias is what the component resolves, so its configuration can name a
  37. # hostname rather than a container name.
  38. - name: Ensure the homeserver stub is running
  39. ansible.builtin.command:
  40. argv:
  41. - docker
  42. - run
  43. - --detach
  44. - --name={{ molecule_shared_stub_name | default('matrix-homeserver-stub') }}
  45. - --network={{ molecule_shared_stub_network }}
  46. - --network-alias={{ molecule_shared_stub_hostname | default('matrix.molecule.local') }}
  47. - --env=STUB_SERVER_NAME={{ molecule_shared_stub_server_name | default('molecule.local') }}
  48. - --env=STUB_JOINED_ROOMS={{ (molecule_shared_stub_joined_rooms | default([])) | join(',') }}
  49. # Appservices call /whoami on startup and refuse to run if the id
  50. # returned is not the bot user they were configured as, so a scenario
  51. # bridging anything has to tell the stub who it should claim to be.
  52. - --env=STUB_USER_ID={{ molecule_shared_stub_user_id | default('@stub:' + (molecule_shared_stub_server_name | default('molecule.local'))) }}
  53. - --volume=/root/molecule-homeserver-stub.py:/stub.py:ro
  54. - "{{ molecule_shared_image_python }}"
  55. - python3
  56. - /stub.py
  57. register: molecule_shared_stub_start
  58. changed_when: molecule_shared_stub_start.rc == 0
  59. - name: Wait for the homeserver stub to answer
  60. ansible.builtin.command:
  61. argv:
  62. - docker
  63. - run
  64. - --rm
  65. - --network={{ molecule_shared_stub_network }}
  66. - "{{ molecule_shared_image_curl }}"
  67. - --silent
  68. - --fail
  69. - --max-time
  70. - "5"
  71. - "http://{{ molecule_shared_stub_hostname | default('matrix.molecule.local') }}:8008/_matrix/client/versions"
  72. register: molecule_shared_stub_ready
  73. changed_when: false
  74. until: molecule_shared_stub_ready.rc == 0
  75. retries: 12
  76. delay: 5