Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

121 líneas
5.3 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. # This one will not be deleted if `matrix_static_files_file_index_html_enabled` flips to `false`.
  59. # See the comment for `matrix_static_files_file_index_html_enabled` to learn why.
  60. - content: "{{ matrix_static_files_file_index_html_template }}"
  61. dest: "{{ matrix_static_files_public_path }}/index.html"
  62. when: "{{ matrix_static_files_file_index_html_enabled }}"
  63. register: matrix_static_files_files_result
  64. - name: Ensure /.well-known/matrix/server file deleted if not enabled
  65. ansible.builtin.file:
  66. path: "{{ matrix_static_files_public_well_known_matrix_path }}/server"
  67. state: absent
  68. when: "not matrix_static_files_file_matrix_server_enabled | bool"
  69. - name: Ensure /.well-known/matrix/support file deleted if not enabled
  70. ansible.builtin.file:
  71. path: "{{ matrix_static_files_public_well_known_matrix_path }}/support"
  72. state: absent
  73. when: "not matrix_static_files_file_matrix_support_enabled | bool"
  74. - name: Ensure matrix-static-files container image is pulled
  75. community.docker.docker_image:
  76. name: "{{ matrix_static_files_container_image }}"
  77. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  78. force_source: "{{ matrix_static_files_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  79. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_static_files_container_image_force_pull }}"
  80. register: matrix_static_files_container_image_pull_result
  81. retries: "{{ devture_playbook_help_container_retries_count }}"
  82. delay: "{{ devture_playbook_help_container_retries_delay }}"
  83. until: matrix_static_files_container_image_pull_result is not failed
  84. - name: Ensure matrix-static-files container network is created
  85. community.general.docker_network:
  86. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  87. name: "{{ matrix_static_files_container_network }}"
  88. driver: bridge
  89. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  90. - name: Ensure matrix-static-files systemd service is installed
  91. ansible.builtin.template:
  92. src: "{{ role_path }}/templates/systemd/matrix-static-files.service.j2"
  93. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_static_files_identifier }}.service"
  94. mode: '0644'
  95. register: matrix_static_files_systemd_service_result
  96. - name: Determine whether matrix-static-files needs a restart
  97. ansible.builtin.set_fact:
  98. matrix_static_files_restart_necessary: >-
  99. {{
  100. matrix_static_files_config_result.changed | default(false)
  101. or matrix_static_files_files_result.changed | default(false)
  102. or matrix_static_files_systemd_service_result.changed | default(false)
  103. or matrix_static_files_container_image_pull_result.changed | default(false)
  104. }}