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

130 строки
5.5 KiB

  1. # SPDX-FileCopyrightText: 2024 David Mehren
  2. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure matrix-static-files paths exist
  7. ansible.builtin.file:
  8. path: "{{ item.path }}"
  9. state: directory
  10. mode: '0750'
  11. owner: "{{ matrix_user_name }}"
  12. group: "{{ matrix_group_name }}"
  13. with_items:
  14. - {path: "{{ matrix_static_files_base_path }}", when: true}
  15. - {path: "{{ matrix_static_files_config_path }}", when: true}
  16. - {path: "{{ matrix_static_files_public_path }}", when: true}
  17. - {path: "{{ matrix_static_files_public_well_known_path }}", when: true}
  18. - {path: "{{ matrix_static_files_public_well_known_matrix_path }}", when: true}
  19. when: "item.when | bool"
  20. # This is not necessary anymore, so we're cleaning it up.
  21. - name: Ensure matrix-static-files element path doesn't exist
  22. ansible.builtin.file:
  23. path: "{{ matrix_static_files_public_well_known_element_path }}"
  24. state: absent
  25. - name: Ensure matrix-static-files is configured
  26. ansible.builtin.template:
  27. src: "{{ item.src }}"
  28. dest: "{{ item.dest }}"
  29. owner: "{{ matrix_user_name }}"
  30. group: "{{ matrix_group_name }}"
  31. mode: '0644'
  32. with_items:
  33. - src: "{{ role_path }}/templates/config.toml.j2"
  34. dest: "{{ matrix_static_files_config_path }}/config.toml"
  35. - src: "{{ role_path }}/templates/env.j2"
  36. dest: "{{ matrix_static_files_base_path }}/env"
  37. - src: "{{ role_path }}/templates/labels.j2"
  38. dest: "{{ matrix_static_files_base_path }}/labels"
  39. register: matrix_static_files_config_result
  40. - name: Ensure matrix-static-files files are installed
  41. ansible.builtin.copy:
  42. content: "{{ item.content }}"
  43. dest: "{{ item.dest }}"
  44. mode: '0644'
  45. owner: "{{ matrix_user_name }}"
  46. group: "{{ matrix_group_name }}"
  47. when: item.when | bool
  48. with_items:
  49. - content: "{{ matrix_static_files_file_matrix_client_configuration | to_nice_json }}"
  50. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/client"
  51. when: true
  52. - content: "{{ matrix_static_files_file_matrix_server_configuration | to_nice_json }}"
  53. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/server"
  54. when: "{{ matrix_static_files_file_matrix_server_enabled }}"
  55. - content: "{{ matrix_static_files_file_matrix_support_configuration | to_nice_json }}"
  56. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
  57. when: "{{ matrix_static_files_file_matrix_support_enabled }}"
  58. - content: "{{ matrix_static_files_file_matrix_mautrix_configuration | to_nice_json }}"
  59. dest: "{{ matrix_static_files_public_well_known_matrix_path }}/mautrix"
  60. when: "{{ matrix_static_files_file_matrix_mautrix_enabled }}"
  61. # This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`.
  62. # See the comment for `matrix_static_files_file_index_html_enabled` to learn why.
  63. - content: "{{ matrix_static_files_file_index_html_template }}"
  64. dest: "{{ matrix_static_files_public_path }}/index.html"
  65. when: "{{ matrix_static_files_file_index_html_enabled }}"
  66. register: matrix_static_files_files_result
  67. - name: Ensure /.well-known/matrix/server file deleted if not enabled
  68. ansible.builtin.file:
  69. path: "{{ matrix_static_files_public_well_known_matrix_path }}/server"
  70. state: absent
  71. when: "not matrix_static_files_file_matrix_server_enabled | bool"
  72. - name: Ensure /.well-known/matrix/support file deleted if not enabled
  73. ansible.builtin.file:
  74. path: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
  75. state: absent
  76. when: "not matrix_static_files_file_matrix_support_enabled | bool"
  77. - name: Ensure /.well-known/matrix/mautrix file deleted if not enabled
  78. ansible.builtin.file:
  79. path: "{{ matrix_static_files_public_well_known_matrix_path }}/mautrix"
  80. state: absent
  81. when: "not matrix_static_files_file_matrix_mautrix_enabled | bool"
  82. - name: Ensure matrix-static-files container image is pulled
  83. community.docker.docker_image_pull:
  84. name: "{{ matrix_static_files_container_image }}"
  85. pull: always
  86. register: matrix_static_files_container_image_pull_result
  87. retries: "{{ devture_playbook_help_container_retries_count }}"
  88. delay: "{{ devture_playbook_help_container_retries_delay }}"
  89. until: matrix_static_files_container_image_pull_result is not failed
  90. - name: Ensure matrix-static-files container network is created
  91. when: matrix_static_files_container_network != 'host'
  92. community.general.docker_network:
  93. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  94. name: "{{ matrix_static_files_container_network }}"
  95. driver: bridge
  96. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  97. - name: Ensure matrix-static-files systemd service is installed
  98. ansible.builtin.template:
  99. src: "{{ role_path }}/templates/systemd/matrix-static-files.service.j2"
  100. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_static_files_identifier }}.service"
  101. mode: '0644'
  102. register: matrix_static_files_systemd_service_result
  103. - name: Determine whether matrix-static-files needs a restart
  104. ansible.builtin.set_fact:
  105. matrix_static_files_restart_necessary: >-
  106. {{
  107. matrix_static_files_config_result.changed | default(false)
  108. or matrix_static_files_files_result.changed | default(false)
  109. or matrix_static_files_systemd_service_result.changed | default(false)
  110. or matrix_static_files_container_image_pull_result.changed | default(false)
  111. }}