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.
 
 

100 line
4.2 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure matrix-static-files paths exist
  6. ansible.builtin.file:
  7. path: "{{ item }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - "{{ matrix_static_files_base_path }}"
  14. - "{{ matrix_static_files_config_path }}"
  15. - "{{ matrix_static_files_public_path }}"
  16. - "{{ matrix_static_files_public_well_known_path }}"
  17. - "{{ matrix_static_files_public_well_known_matrix_path }}"
  18. - name: Ensure matrix-static-files is configured
  19. ansible.builtin.template:
  20. src: "{{ item.src }}"
  21. dest: "{{ item.dest }}"
  22. owner: "{{ matrix_user_username }}"
  23. group: "{{ matrix_user_groupname }}"
  24. mode: 0644
  25. with_items:
  26. - src: "{{ role_path }}/templates/config.toml.j2"
  27. dest: "{{ matrix_static_files_config_path }}/config.toml"
  28. - src: "{{ role_path }}/templates/env.j2"
  29. dest: "{{ matrix_static_files_base_path }}/env"
  30. - src: "{{ role_path }}/templates/labels.j2"
  31. dest: "{{ matrix_static_files_base_path }}/labels"
  32. - name: Ensure matrix-static-files files are installed
  33. ansible.builtin.copy:
  34. content: "{{ item.content }}"
  35. dest: "{{ item.dest }}"
  36. mode: 0644
  37. owner: "{{ matrix_user_username }}"
  38. group: "{{ matrix_user_groupname }}"
  39. when: item.when | bool
  40. with_items:
  41. - content: "{{ matrix_static_files_file_matrix_client_configuration | to_nice_json }}"
  42. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/client"
  43. when: true
  44. - content: "{{ matrix_static_files_file_matrix_server_configuration | to_nice_json }}"
  45. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/server"
  46. when: "{{ matrix_static_files_file_matrix_server_enabled }}"
  47. - content: "{{ matrix_static_files_file_matrix_support_configuration | to_nice_json }}"
  48. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
  49. when: "{{ matrix_static_files_file_matrix_support_enabled }}"
  50. # This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`.
  51. # See the comment for `matrix_static_files_file_index_html_enabled` to learn why.
  52. - content: "{{ matrix_static_files_file_index_html_template }}"
  53. dest: "{{ matrix_static_files_public_path }}/index.html"
  54. when: "{{ matrix_static_files_file_index_html_enabled }}"
  55. - name: Ensure /.well-known/matrix/server file deleted if not enabled
  56. ansible.builtin.file:
  57. path: "{{ matrix_static_files_public_well_known_matrix_path }}/server"
  58. state: absent
  59. when: "not matrix_static_files_file_matrix_server_enabled | bool"
  60. - name: Ensure /.well-known/matrix/support file deleted if not enabled
  61. ansible.builtin.file:
  62. path: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
  63. state: absent
  64. when: "not matrix_static_files_file_matrix_support_enabled | bool"
  65. - name: Ensure matrix-static-files container image is pulled
  66. community.docker.docker_image:
  67. name: "{{ matrix_static_files_container_image }}"
  68. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  69. force_source: "{{ matrix_static_files_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  70. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_static_files_container_image_force_pull }}"
  71. register: result
  72. retries: "{{ devture_playbook_help_container_retries_count }}"
  73. delay: "{{ devture_playbook_help_container_retries_delay }}"
  74. until: result is not failed
  75. - name: Ensure matrix-static-files container network is created
  76. community.general.docker_network:
  77. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  78. name: "{{ matrix_static_files_container_network }}"
  79. driver: bridge
  80. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  81. - name: Ensure matrix-static-files systemd service is installed
  82. ansible.builtin.template:
  83. src: "{{ role_path }}/templates/systemd/matrix-static-files.service.j2"
  84. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_static_files_identifier }}.service"
  85. mode: 0644