Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

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