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

148 строки
6.7 KiB

  1. # SPDX-FileCopyrightText: 2023 Nikita Chernyi
  2. # SPDX-FileCopyrightText: 2023 Pierre 'McFly' Marty
  3. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  4. # SPDX-FileCopyrightText: 2024 David Mehren
  5. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  6. #
  7. # SPDX-License-Identifier: AGPL-3.0-or-later
  8. ---
  9. - name: Ensure SchildiChat Web paths exists
  10. ansible.builtin.file:
  11. path: "{{ item.path }}"
  12. state: directory
  13. mode: '0750'
  14. owner: "{{ matrix_user_name }}"
  15. group: "{{ matrix_group_name }}"
  16. with_items:
  17. - {path: "{{ matrix_client_schildichat_data_path }}", when: true}
  18. - {path: "{{ matrix_client_schildichat_container_src_files_path }}", when: "{{ matrix_client_schildichat_container_image_self_build }}"}
  19. when: "item.when | bool"
  20. - name: Ensure SchildiChat Web container image is pulled
  21. community.docker.docker_image_pull:
  22. name: "{{ matrix_client_schildichat_container_image }}"
  23. pull: always
  24. when: "not matrix_client_schildichat_container_image_self_build | bool"
  25. register: matrix_client_schildichat_container_image_pull_result
  26. retries: "{{ devture_playbook_help_container_retries_count }}"
  27. delay: "{{ devture_playbook_help_container_retries_delay }}"
  28. until: matrix_client_schildichat_container_image_pull_result is not failed
  29. - when: "matrix_client_schildichat_container_image_self_build | bool"
  30. block:
  31. # A checkout owned by a different user (a uid change, an earlier clone by another user, etc.) would make the git task below fail on ownership or permissions.
  32. - name: Ensure SchildiChat Web repository ownership is correct on self-build
  33. ansible.builtin.file:
  34. path: "{{ matrix_client_schildichat_container_src_files_path }}"
  35. state: directory
  36. owner: "{{ matrix_user_name }}"
  37. group: "{{ matrix_group_name }}"
  38. recurse: true
  39. - name: Ensure SchildiChat Web repository is present on self-build
  40. ansible.builtin.git:
  41. repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}"
  42. dest: "{{ matrix_client_schildichat_container_src_files_path }}"
  43. version: "{{ matrix_client_schildichat_container_image_self_build_version }}"
  44. force: "yes"
  45. become: true
  46. become_user: "{{ matrix_user_name }}"
  47. # Keep this even though the task above normalizes ownership. Git may still see an ownership mismatch when Ansible becomes an unprivileged user (see #5065).
  48. environment:
  49. GIT_CONFIG_COUNT: "1"
  50. GIT_CONFIG_KEY_0: safe.directory
  51. GIT_CONFIG_VALUE_0: "{{ matrix_client_schildichat_container_src_files_path }}"
  52. register: matrix_client_schildichat_git_pull_results
  53. # See:
  54. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357
  55. # - https://github.com/vector-im/schildichat-web/issues/19544 — # Update (2023-12-15): 404
  56. - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices
  57. ansible.builtin.lineinfile:
  58. path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js"
  59. regexp: '(\s+)splitChunks: \{'
  60. line: '\1splitChunks: { maxSize: 100000,'
  61. backrefs: true
  62. owner: root
  63. group: root
  64. mode: '0644'
  65. when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool"
  66. - name: Ensure SchildiChat Web container image is built
  67. ansible.builtin.command:
  68. cmd: |-
  69. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  70. --tag={{ matrix_client_schildichat_container_image }}
  71. --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile
  72. {{ matrix_client_schildichat_container_src_files_path }}
  73. changed_when: true
  74. - name: Ensure SchildiChat Web configuration installed
  75. ansible.builtin.copy:
  76. content: "{{ matrix_client_schildichat_configuration | to_nice_json }}"
  77. dest: "{{ matrix_client_schildichat_data_path }}/config.json"
  78. mode: '0644'
  79. owner: "{{ matrix_user_name }}"
  80. group: "{{ matrix_group_name }}"
  81. register: matrix_client_schildichat_config_result
  82. - name: Ensure SchildiChat location sharing map style installed
  83. when: matrix_client_schildichat_location_sharing_enabled | bool
  84. ansible.builtin.copy:
  85. content: "{{ matrix_client_schildichat_location_sharing_map_style | to_nice_json }}"
  86. dest: "{{ matrix_client_schildichat_data_path }}/map_style.json"
  87. mode: '0644'
  88. owner: "{{ matrix_user_name }}"
  89. group: "{{ matrix_group_name }}"
  90. register: matrix_client_schildichat_config_map_style_result
  91. - name: Ensure SchildiChat Web config files installed
  92. ansible.builtin.template:
  93. src: "{{ item.src }}"
  94. dest: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  95. mode: '0644'
  96. owner: "{{ matrix_user_name }}"
  97. group: "{{ matrix_group_name }}"
  98. with_items:
  99. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  100. - {src: "{{ matrix_client_schildichat_page_template_welcome_path }}", name: "welcome.html"}
  101. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  102. when: "item.src is not none"
  103. register: matrix_client_schildichat_support_files_result
  104. - name: Ensure SchildiChat Web config files removed
  105. ansible.builtin.file:
  106. path: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  107. state: absent
  108. with_items:
  109. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  110. when: "item.src is none"
  111. - name: Ensure SchildiChat Web container network is created
  112. when: matrix_client_schildichat_container_network != 'host'
  113. community.general.docker_network:
  114. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  115. name: "{{ matrix_client_schildichat_container_network }}"
  116. driver: bridge
  117. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  118. - name: Ensure matrix-client-schildichat.service installed
  119. ansible.builtin.template:
  120. src: "{{ role_path }}/templates/systemd/matrix-client-schildichat.service.j2"
  121. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-schildichat.service"
  122. mode: '0644'
  123. register: matrix_client_schildichat_systemd_service_result
  124. - name: Determine whether SchildiChat Web needs a restart
  125. ansible.builtin.set_fact:
  126. matrix_client_schildichat_restart_necessary: >-
  127. {{
  128. matrix_client_schildichat_config_result.changed | default(false)
  129. or matrix_client_schildichat_config_map_style_result.changed | default(false)
  130. or matrix_client_schildichat_support_files_result.changed | default(false)
  131. or matrix_client_schildichat_systemd_service_result.changed | default(false)
  132. or matrix_client_schildichat_container_image_pull_result.changed | default(false)
  133. }}