Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

112 lines
5.0 KiB

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