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

116 строки
5.1 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure SchildiChat Web paths exists
  6. ansible.builtin.file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - {path: "{{ matrix_client_schildichat_data_path }}", when: true}
  14. - {path: "{{ matrix_client_schildichat_container_src_files_path }}", when: "{{ matrix_client_schildichat_container_image_self_build }}"}
  15. when: "item.when | bool"
  16. - name: Ensure SchildiChat Web container image is pulled
  17. community.docker.docker_image:
  18. name: "{{ matrix_client_schildichat_docker_image }}"
  19. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  20. force_source: "{{ matrix_client_schildichat_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  21. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_client_schildichat_docker_image_force_pull }}"
  22. when: "not matrix_client_schildichat_container_image_self_build | bool"
  23. register: result
  24. retries: "{{ devture_playbook_help_container_retries_count }}"
  25. delay: "{{ devture_playbook_help_container_retries_delay }}"
  26. until: result is not failed
  27. - when: "matrix_client_schildichat_container_image_self_build | bool"
  28. block:
  29. - name: Ensure SchildiChat Web repository is present on self-build
  30. ansible.builtin.git:
  31. repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}"
  32. dest: "{{ matrix_client_schildichat_container_src_files_path }}"
  33. version: "{{ matrix_client_schildichat_container_image_self_build_version }}"
  34. force: "yes"
  35. become: true
  36. become_user: "{{ matrix_user_username }}"
  37. register: matrix_client_schildichat_git_pull_results
  38. # See:
  39. # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357
  40. # - https://github.com/vector-im/schildichat-web/issues/19544 -- # Update (2023-12-15): 404
  41. - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices
  42. ansible.builtin.lineinfile:
  43. path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js"
  44. regexp: '(\s+)splitChunks: \{'
  45. line: '\1splitChunks: { maxSize: 100000,'
  46. backrefs: true
  47. owner: root
  48. group: root
  49. mode: '0644'
  50. when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool"
  51. - name: Ensure SchildiChat Web container image is built
  52. ansible.builtin.command:
  53. cmd: |-
  54. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  55. --tag={{ matrix_client_schildichat_docker_image }}
  56. --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile
  57. {{ matrix_client_schildichat_container_src_files_path }}
  58. changed_when: true
  59. - name: Ensure SchildiChat Web configuration installed
  60. ansible.builtin.copy:
  61. content: "{{ matrix_client_schildichat_configuration | to_nice_json }}"
  62. dest: "{{ matrix_client_schildichat_data_path }}/config.json"
  63. mode: 0644
  64. owner: "{{ matrix_user_username }}"
  65. group: "{{ matrix_user_groupname }}"
  66. - name: Ensure SchildiChat location sharing map style installed
  67. when: matrix_client_schildichat_location_sharing_enabled | bool
  68. ansible.builtin.copy:
  69. content: "{{ matrix_client_schildichat_location_sharing_map_style | to_nice_json }}"
  70. dest: "{{ matrix_client_schildichat_data_path }}/map_style.json"
  71. mode: 0644
  72. owner: "{{ matrix_user_username }}"
  73. group: "{{ matrix_user_groupname }}"
  74. - name: Ensure SchildiChat Web config files installed
  75. ansible.builtin.template:
  76. src: "{{ item.src }}"
  77. dest: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  78. mode: 0644
  79. owner: "{{ matrix_user_username }}"
  80. group: "{{ matrix_user_groupname }}"
  81. with_items:
  82. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  83. - {src: "{{ matrix_client_schildichat_page_template_welcome_path }}", name: "welcome.html"}
  84. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  85. when: "item.src is not none"
  86. - name: Ensure SchildiChat Web config files removed
  87. ansible.builtin.file:
  88. path: "{{ matrix_client_schildichat_data_path }}/{{ item.name }}"
  89. state: absent
  90. with_items:
  91. - {src: "{{ matrix_client_schildichat_embedded_pages_home_path }}", name: "home.html"}
  92. when: "item.src is none"
  93. - name: Ensure SchildiChat Web container network is created
  94. community.general.docker_network:
  95. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  96. name: "{{ matrix_client_schildichat_container_network }}"
  97. driver: bridge
  98. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  99. - name: Ensure matrix-client-schildichat.service installed
  100. ansible.builtin.template:
  101. src: "{{ role_path }}/templates/systemd/matrix-client-schildichat.service.j2"
  102. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-schildichat.service"
  103. mode: 0644