Matrix Docker Ansible eploy
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

135 linhas
6.1 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:
  22. name: "{{ matrix_client_schildichat_docker_image }}"
  23. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  24. force_source: "{{ matrix_client_schildichat_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  25. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_client_schildichat_docker_image_force_pull }}"
  26. when: "not matrix_client_schildichat_container_image_self_build | bool"
  27. register: matrix_client_schildichat_container_image_pull_result
  28. retries: "{{ devture_playbook_help_container_retries_count }}"
  29. delay: "{{ devture_playbook_help_container_retries_delay }}"
  30. until: matrix_client_schildichat_container_image_pull_result is not failed
  31. - when: "matrix_client_schildichat_container_image_self_build | bool"
  32. block:
  33. - name: Ensure SchildiChat Web repository is present on self-build
  34. ansible.builtin.git:
  35. repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}"
  36. dest: "{{ matrix_client_schildichat_container_src_files_path }}"
  37. version: "{{ matrix_client_schildichat_container_image_self_build_version }}"
  38. force: "yes"
  39. become: true
  40. become_user: "{{ matrix_user_name }}"
  41. register: matrix_client_schildichat_git_pull_results
  42. # See:
  43. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357
  44. # - https://github.com/vector-im/schildichat-web/issues/19544 — # Update (2023-12-15): 404
  45. - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices
  46. ansible.builtin.lineinfile:
  47. path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js"
  48. regexp: '(\s+)splitChunks: \{'
  49. line: '\1splitChunks: { maxSize: 100000,'
  50. backrefs: true
  51. owner: root
  52. group: root
  53. mode: '0644'
  54. when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool"
  55. - name: Ensure SchildiChat Web container image is built
  56. ansible.builtin.command:
  57. cmd: |-
  58. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  59. --tag={{ matrix_client_schildichat_docker_image }}
  60. --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile
  61. {{ matrix_client_schildichat_container_src_files_path }}
  62. changed_when: true
  63. - name: Ensure SchildiChat Web configuration installed
  64. ansible.builtin.copy:
  65. content: "{{ matrix_client_schildichat_configuration | to_nice_json }}"
  66. dest: "{{ matrix_client_schildichat_data_path }}/config.json"
  67. mode: 0644
  68. owner: "{{ matrix_user_name }}"
  69. group: "{{ matrix_group_name }}"
  70. register: matrix_client_schildichat_config_result
  71. - name: Ensure SchildiChat location sharing map style installed
  72. when: matrix_client_schildichat_location_sharing_enabled | bool
  73. ansible.builtin.copy:
  74. content: "{{ matrix_client_schildichat_location_sharing_map_style | to_nice_json }}"
  75. dest: "{{ matrix_client_schildichat_data_path }}/map_style.json"
  76. mode: 0644
  77. owner: "{{ matrix_user_name }}"
  78. group: "{{ matrix_group_name }}"
  79. register: matrix_client_schildichat_config_map_style_result
  80. - name: Ensure SchildiChat Web config files installed
  81. ansible.builtin.template:
  82. src: "{{ item.src }}"
  83. dest: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  84. mode: 0644
  85. owner: "{{ matrix_user_name }}"
  86. group: "{{ matrix_group_name }}"
  87. with_items:
  88. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  89. - {src: "{{ matrix_client_schildichat_page_template_welcome_path }}", name: "welcome.html"}
  90. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  91. when: "item.src is not none"
  92. register: matrix_client_schildichat_support_files_result
  93. - name: Ensure SchildiChat Web config files removed
  94. ansible.builtin.file:
  95. path: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  96. state: absent
  97. with_items:
  98. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  99. when: "item.src is none"
  100. - name: Ensure SchildiChat Web container network is created
  101. community.general.docker_network:
  102. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  103. name: "{{ matrix_client_schildichat_container_network }}"
  104. driver: bridge
  105. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  106. - name: Ensure matrix-client-schildichat.service installed
  107. ansible.builtin.template:
  108. src: "{{ role_path }}/templates/systemd/matrix-client-schildichat.service.j2"
  109. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-schildichat.service"
  110. mode: 0644
  111. register: matrix_client_schildichat_systemd_service_result
  112. - name: Determine whether SchildiChat Web needs a restart
  113. ansible.builtin.set_fact:
  114. matrix_client_schildichat_restart_necessary: >-
  115. {{
  116. matrix_client_schildichat_config_result.changed | default(false)
  117. or matrix_client_schildichat_config_map_style_result.changed | default(false)
  118. or matrix_client_schildichat_support_files_result.changed | default(false)
  119. or matrix_client_schildichat_systemd_service_result.changed | default(false)
  120. or matrix_client_schildichat_container_image_pull_result.changed | default(false)
  121. }}