Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

174 lignes
7.0 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2023 Johan Swetzén
  3. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  4. # SPDX-FileCopyrightText: 2024 David Mehren
  5. #
  6. # SPDX-License-Identifier: AGPL-3.0-or-later
  7. ---
  8. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  9. # We don't want to fail in such cases.
  10. - name: Fail if matrix-synapse role already executed
  11. ansible.builtin.fail:
  12. msg: >-
  13. The matrix-bridge-mautrix-wsproxy role needs to execute before the matrix-synapse role.
  14. when: "matrix_synapse_role_executed|default(False)"
  15. - ansible.builtin.set_fact:
  16. matrix_mautrix_wsproxy_migration_requires_restart: false
  17. - ansible.builtin.set_fact:
  18. matrix_mautrix_wsproxy_syncproxy_migration_requires_restart: false
  19. - name: Ensure Mautrix wsproxy paths exist
  20. ansible.builtin.file:
  21. path: "{{ item.path }}"
  22. state: directory
  23. mode: '0750'
  24. owner: "{{ matrix_user_name }}"
  25. group: "{{ matrix_group_name }}"
  26. with_items:
  27. - path: "{{ matrix_mautrix_wsproxy_base_path }}"
  28. when: true
  29. when: item.when | bool
  30. - name: Ensure Mautrix wsproxy support files installed
  31. ansible.builtin.template:
  32. src: "{{ role_path }}/templates/{{ item }}.j2"
  33. dest: "{{ matrix_mautrix_wsproxy_base_path }}/{{ item }}"
  34. mode: '0640'
  35. owner: "{{ matrix_user_name }}"
  36. group: "{{ matrix_group_name }}"
  37. with_items:
  38. - syncproxy-env
  39. - wsproxy-labels
  40. register: matrix_mautrix_wsproxy_support_files_result
  41. - name: Ensure Mautrix wsproxy image is pulled
  42. community.docker.docker_image_pull:
  43. name: "{{ matrix_mautrix_wsproxy_container_image }}"
  44. pull: always
  45. register: matrix_mautrix_wsproxy_container_image_pull_result
  46. retries: "{{ devture_playbook_help_container_retries_count }}"
  47. delay: "{{ devture_playbook_help_container_retries_delay }}"
  48. until: matrix_mautrix_wsproxy_container_image_pull_result is not failed
  49. - name: Ensure Mautrix syncproxy image is pulled
  50. community.docker.docker_image_pull:
  51. name: "{{ matrix_mautrix_wsproxy_syncproxy_container_image }}"
  52. pull: always
  53. register: matrix_mautrix_wsproxy_syncproxy_container_image_pull_result
  54. retries: "{{ devture_playbook_help_container_retries_count }}"
  55. delay: "{{ devture_playbook_help_container_retries_delay }}"
  56. until: matrix_mautrix_wsproxy_syncproxy_container_image_pull_result is not failed
  57. - name: Ensure Mautrix wsproxy paths exists
  58. ansible.builtin.file:
  59. path: "{{ item }}"
  60. state: directory
  61. mode: '0750'
  62. owner: "{{ matrix_user_name }}"
  63. group: "{{ matrix_group_name }}"
  64. with_items:
  65. - "{{ matrix_mautrix_wsproxy_base_path }}"
  66. - "{{ matrix_mautrix_wsproxy_config_path }}"
  67. - name: Check if an old Matrix state file exists
  68. ansible.builtin.stat:
  69. path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json"
  70. register: matrix_mautrix_wsproxy_stat_mx_state
  71. - name: Ensure mautrix-wsproxy config.yaml installed
  72. ansible.builtin.copy:
  73. content: "{{ matrix_mautrix_wsproxy_configuration | to_nice_yaml }}"
  74. dest: "{{ matrix_mautrix_wsproxy_config_path }}/config.yaml"
  75. mode: '0644'
  76. owner: "{{ matrix_user_name }}"
  77. group: "{{ matrix_group_name }}"
  78. register: matrix_mautrix_wsproxy_config_result
  79. - name: Ensure mautrix-androidsms registration.yaml installed
  80. ansible.builtin.copy:
  81. content: "{{ matrix_mautrix_androidsms_registration | to_nice_yaml }}"
  82. dest: "{{ matrix_mautrix_wsproxy_config_path }}/androidsms-registration.yaml"
  83. mode: '0644'
  84. owner: "{{ matrix_user_name }}"
  85. group: "{{ matrix_group_name }}"
  86. register: matrix_mautrix_wsproxy_registration_androidsms_result
  87. - name: Ensure mautrix-imessage registration.yaml installed
  88. ansible.builtin.copy:
  89. content: "{{ matrix_mautrix_imessage_registration | to_nice_yaml }}"
  90. dest: "{{ matrix_mautrix_wsproxy_config_path }}/imessage-registration.yaml"
  91. mode: '0644'
  92. owner: "{{ matrix_user_name }}"
  93. group: "{{ matrix_group_name }}"
  94. register: matrix_mautrix_wsproxy_registration_imessage_result
  95. - name: Ensure mautrix-wsproxy container network is created
  96. when: matrix_mautrix_wsproxy_container_network != 'host'
  97. community.general.docker_network:
  98. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  99. name: "{{ matrix_mautrix_wsproxy_container_network }}"
  100. driver: bridge
  101. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  102. - name: Ensure matrix-mautrix-wsproxy.service installed
  103. ansible.builtin.template:
  104. src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy.service.j2"
  105. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy.service"
  106. mode: '0644'
  107. register: matrix_mautrix_wsproxy_systemd_service_result
  108. - name: Determine whether Mautrix wsproxy needs a restart
  109. ansible.builtin.set_fact:
  110. matrix_mautrix_wsproxy_restart_necessary: >-
  111. {{
  112. matrix_mautrix_wsproxy_migration_requires_restart | default(false)
  113. or matrix_mautrix_wsproxy_support_files_result.changed | default(false)
  114. or matrix_mautrix_wsproxy_config_result.changed | default(false)
  115. or matrix_mautrix_wsproxy_registration_androidsms_result.changed | default(false)
  116. or matrix_mautrix_wsproxy_registration_imessage_result.changed | default(false)
  117. or matrix_mautrix_wsproxy_systemd_service_result.changed | default(false)
  118. or matrix_mautrix_wsproxy_container_image_pull_result.changed | default(false)
  119. }}
  120. - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation
  121. ansible.builtin.service:
  122. daemon_reload: true
  123. when: "matrix_mautrix_wsproxy_systemd_service_result.changed"
  124. - name: Ensure matrix-mautrix-wsproxy.service restarted, if necessary
  125. ansible.builtin.service:
  126. name: "matrix-mautrix-wsproxy.service"
  127. state: restarted
  128. when: "matrix_mautrix_wsproxy_migration_requires_restart|bool"
  129. - name: Ensure matrix-mautrix-wsproxy-syncproxy.service installed
  130. ansible.builtin.template:
  131. src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy-syncproxy.service.j2"
  132. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-wsproxy-syncproxy.service"
  133. mode: '0644'
  134. register: matrix_mautrix_wsproxy_syncproxy_systemd_service_result
  135. - name: Determine whether Mautrix wsproxy syncproxy needs a restart
  136. ansible.builtin.set_fact:
  137. matrix_mautrix_wsproxy_syncproxy_restart_necessary: >-
  138. {{
  139. matrix_mautrix_wsproxy_syncproxy_migration_requires_restart | default(false)
  140. or matrix_mautrix_wsproxy_syncproxy_systemd_service_result.changed | default(false)
  141. or matrix_mautrix_wsproxy_syncproxy_container_image_pull_result.changed | default(false)
  142. }}
  143. - name: Ensure systemd reloaded after matrix-mautrix-wsproxy-syncproxy.service installation
  144. ansible.builtin.service:
  145. daemon_reload: true
  146. when: "matrix_mautrix_wsproxy_syncproxy_systemd_service_result.changed"
  147. - name: Ensure matrix-mautrix-wsproxy-syncproxy.service restarted, if necessary
  148. ansible.builtin.service:
  149. name: "matrix-mautrix-wsproxy-syncproxy.service"
  150. state: restarted
  151. when: "matrix_mautrix_wsproxy_syncproxy_migration_requires_restart|bool"