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

127 строки
5.6 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. # Proves heisenbridge starts, reads the registration the role rendered, and is the version
  6. # the role pins. It does NOT connect to IRC. See docs/molecule-testing.md.
  7. - name: Verify heisenbridge
  8. hosts: all
  9. become: true
  10. vars_files:
  11. - "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
  12. - "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
  13. gather_facts: false
  14. tasks:
  15. - name: Load the role's defaults under a separate name
  16. ansible.builtin.include_vars:
  17. file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/main.yml"
  18. name: heisenbridge_role_defaults
  19. - name: Wait for the heisenbridge service to become active
  20. ansible.builtin.systemd_service:
  21. name: matrix-heisenbridge.service
  22. register: heisenbridge_service
  23. until: heisenbridge_service.status.ActiveState == 'active'
  24. retries: 30
  25. delay: 5
  26. failed_when: false
  27. # `Restart=always` means a bridge crash-looping on unreadable config still reports
  28. # `active`, so the restart counter is checked too.
  29. - name: Assert the service is active and has not been restarting
  30. ansible.builtin.assert:
  31. that:
  32. - heisenbridge_service.status.ActiveState == 'active'
  33. - heisenbridge_service.status.NRestarts is defined
  34. - heisenbridge_service.status.NRestarts | int == 0
  35. fail_msg: >-
  36. matrix-heisenbridge.service is
  37. {{ heisenbridge_service.status.ActiveState | default('unknown') }}
  38. after {{ heisenbridge_service.status.NRestarts | default('?') }}
  39. automatic restart(s)
  40. success_msg: "matrix-heisenbridge.service is active and has not restarted"
  41. # Heisenbridge keeps everything directly under its base path, unlike the mautrix bridges.
  42. - name: Read the appservice registration the role rendered
  43. ansible.builtin.slurp:
  44. src: "{{ matrix_bridge_heisenbridge_base_path }}/registration.yaml"
  45. register: heisenbridge_registration_file
  46. # Token and URL both differ from anything heisenbridge would pick on its own, so their
  47. # presence means the role rendered this file rather than the bridge generating one.
  48. - name: Assert the registration carries the scenario's token and namespace
  49. ansible.builtin.assert:
  50. that:
  51. - matrix_bridge_heisenbridge_appservice_token in heisenbridge_registration_rendered
  52. - "'heisenbridge' in heisenbridge_registration_rendered"
  53. fail_msg: "The appservice registration does not carry the scenario's token"
  54. success_msg: "The appservice registration carries the scenario's token"
  55. vars:
  56. heisenbridge_registration_rendered: "{{ heisenbridge_registration_file.content | b64decode }}"
  57. # The role passes the owner on the command line rather than through a config file,
  58. # so the unit is where it can be checked.
  59. - name: Read the systemd unit the role rendered
  60. ansible.builtin.slurp:
  61. src: /etc/systemd/system/matrix-heisenbridge.service
  62. register: heisenbridge_unit_file
  63. - name: Assert the unit carries the owner and homeserver URL the scenario set
  64. ansible.builtin.assert:
  65. that:
  66. - matrix_bridge_heisenbridge_owner in heisenbridge_unit_rendered
  67. - matrix_bridge_heisenbridge_homeserver_url in heisenbridge_unit_rendered
  68. fail_msg: "The unit does not carry the scenario's owner and homeserver URL"
  69. success_msg: "The unit carries the scenario's owner and homeserver URL"
  70. vars:
  71. heisenbridge_unit_rendered: "{{ heisenbridge_unit_file.content | b64decode }}"
  72. # identd binds host port 113 when enabled. Asserting its absence keeps the default from
  73. # silently becoming "on".
  74. - name: Assert identd is not published while it is disabled
  75. ansible.builtin.assert:
  76. that:
  77. - "'-p 113:' not in (heisenbridge_unit_file.content | b64decode)"
  78. fail_msg: >-
  79. The unit publishes identd on port 113 even though
  80. matrix_bridge_heisenbridge_identd_enabled is false
  81. success_msg: "identd is not published while it is disabled"
  82. - name: Read the image of the running container
  83. ansible.builtin.command:
  84. argv:
  85. - docker
  86. - container
  87. - inspect
  88. - matrix-heisenbridge
  89. - --format
  90. - "{{ '{{' }} .Config.Image {{ '}}' }}"
  91. register: heisenbridge_image
  92. changed_when: false
  93. - name: Assert the running container is the version defaults/main.yml pins
  94. ansible.builtin.assert:
  95. that:
  96. - heisenbridge_role_defaults.matrix_bridge_heisenbridge_version | string in heisenbridge_image.stdout
  97. fail_msg: >-
  98. The running container is {{ heisenbridge_image.stdout }}, which does not
  99. carry the pinned version
  100. {{ heisenbridge_role_defaults.matrix_bridge_heisenbridge_version }}
  101. success_msg: "The running container is the version defaults/main.yml pins"
  102. - name: Read the labels the role rendered
  103. ansible.builtin.slurp:
  104. src: "{{ matrix_bridge_heisenbridge_base_path }}/labels"
  105. register: heisenbridge_labels
  106. - name: Assert no Traefik labels are emitted while Traefik support is disabled
  107. ansible.builtin.assert:
  108. that:
  109. - "'traefik.' not in (heisenbridge_labels.content | b64decode)"
  110. fail_msg: >-
  111. Traefik labels were emitted even though
  112. matrix_bridge_heisenbridge_container_labels_traefik_enabled is false
  113. success_msg: "No Traefik labels are emitted while Traefik support is disabled"