Matrix Docker Ansible eploy
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

143 rindas
6.3 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. register: matrix_client_schildichat_git_pull_results
  48. # See:
  49. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357
  50. # - https://github.com/vector-im/schildichat-web/issues/19544 — # Update (2023-12-15): 404
  51. - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices
  52. ansible.builtin.lineinfile:
  53. path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js"
  54. regexp: '(\s+)splitChunks: \{'
  55. line: '\1splitChunks: { maxSize: 100000,'
  56. backrefs: true
  57. owner: root
  58. group: root
  59. mode: '0644'
  60. when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool"
  61. - name: Ensure SchildiChat Web container image is built
  62. ansible.builtin.command:
  63. cmd: |-
  64. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  65. --tag={{ matrix_client_schildichat_container_image }}
  66. --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile
  67. {{ matrix_client_schildichat_container_src_files_path }}
  68. changed_when: true
  69. - name: Ensure SchildiChat Web configuration installed
  70. ansible.builtin.copy:
  71. content: "{{ matrix_client_schildichat_configuration | to_nice_json }}"
  72. dest: "{{ matrix_client_schildichat_data_path }}/config.json"
  73. mode: '0644'
  74. owner: "{{ matrix_user_name }}"
  75. group: "{{ matrix_group_name }}"
  76. register: matrix_client_schildichat_config_result
  77. - name: Ensure SchildiChat location sharing map style installed
  78. when: matrix_client_schildichat_location_sharing_enabled | bool
  79. ansible.builtin.copy:
  80. content: "{{ matrix_client_schildichat_location_sharing_map_style | to_nice_json }}"
  81. dest: "{{ matrix_client_schildichat_data_path }}/map_style.json"
  82. mode: '0644'
  83. owner: "{{ matrix_user_name }}"
  84. group: "{{ matrix_group_name }}"
  85. register: matrix_client_schildichat_config_map_style_result
  86. - name: Ensure SchildiChat Web config files installed
  87. ansible.builtin.template:
  88. src: "{{ item.src }}"
  89. dest: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  90. mode: '0644'
  91. owner: "{{ matrix_user_name }}"
  92. group: "{{ matrix_group_name }}"
  93. with_items:
  94. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  95. - {src: "{{ matrix_client_schildichat_page_template_welcome_path }}", name: "welcome.html"}
  96. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  97. when: "item.src is not none"
  98. register: matrix_client_schildichat_support_files_result
  99. - name: Ensure SchildiChat Web config files removed
  100. ansible.builtin.file:
  101. path: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  102. state: absent
  103. with_items:
  104. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  105. when: "item.src is none"
  106. - name: Ensure SchildiChat Web container network is created
  107. when: matrix_client_schildichat_container_network != 'host'
  108. community.general.docker_network:
  109. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  110. name: "{{ matrix_client_schildichat_container_network }}"
  111. driver: bridge
  112. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  113. - name: Ensure matrix-client-schildichat.service installed
  114. ansible.builtin.template:
  115. src: "{{ role_path }}/templates/systemd/matrix-client-schildichat.service.j2"
  116. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-schildichat.service"
  117. mode: '0644'
  118. register: matrix_client_schildichat_systemd_service_result
  119. - name: Determine whether SchildiChat Web needs a restart
  120. ansible.builtin.set_fact:
  121. matrix_client_schildichat_restart_necessary: >-
  122. {{
  123. matrix_client_schildichat_config_result.changed | default(false)
  124. or matrix_client_schildichat_config_map_style_result.changed | default(false)
  125. or matrix_client_schildichat_support_files_result.changed | default(false)
  126. or matrix_client_schildichat_systemd_service_result.changed | default(false)
  127. or matrix_client_schildichat_container_image_pull_result.changed | default(false)
  128. }}