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

131 строка
5.8 KiB

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