Matrix Docker Ansible eploy
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

115 rindas
4.7 KiB

  1. # SPDX-FileCopyrightText: 2025 Nikita Chernyi
  2. # SPDX-FileCopyrightText: 2026 MDAD project contributors
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure Commet paths exist
  7. ansible.builtin.file:
  8. path: "{{ item }}"
  9. state: directory
  10. mode: "0750"
  11. owner: "{{ matrix_user_name }}"
  12. group: "{{ matrix_group_name }}"
  13. with_items:
  14. - "{{ matrix_client_commet_base_path }}"
  15. - "{{ matrix_client_commet_config_path }}"
  16. - name: Ensure Commet container image is pulled
  17. community.docker.docker_image_pull:
  18. name: "{{ matrix_client_commet_container_image }}"
  19. pull: always
  20. when: "not matrix_client_commet_container_image_self_build | bool"
  21. register: matrix_client_commet_image_pull_result
  22. retries: "{{ devture_playbook_help_container_retries_count }}"
  23. delay: "{{ devture_playbook_help_container_retries_delay }}"
  24. until: matrix_client_commet_image_pull_result is not failed
  25. - when: "matrix_client_commet_container_image_self_build | bool"
  26. block:
  27. - name: Check Commet git repository metadata exists
  28. ansible.builtin.stat:
  29. path: "{{ matrix_client_commet_container_src_path }}/.git/config"
  30. register: matrix_client_commet_git_config_file_stat
  31. - name: Remove Commet source directory if git remote is misconfigured
  32. ansible.builtin.file:
  33. path: "{{ matrix_client_commet_container_src_path }}"
  34. state: absent
  35. when: not matrix_client_commet_git_config_file_stat.stat.exists
  36. become: true
  37. - name: Ensure Commet repository is present on self-build
  38. ansible.builtin.git:
  39. repo: "{{ matrix_client_commet_container_image_self_build_repo }}"
  40. dest: "{{ matrix_client_commet_container_src_path }}"
  41. version: "{{ matrix_client_commet_version }}"
  42. force: "yes"
  43. become: true
  44. become_user: "{{ matrix_user_name }}"
  45. register: matrix_client_commet_git_pull_results
  46. - name: Set git hash fact
  47. ansible.builtin.set_fact:
  48. matrix_client_commet_container_image_self_build_git_hash: "{{ matrix_client_commet_git_pull_results.after }}"
  49. - name: Ensure Commet container image is built
  50. ansible.builtin.command:
  51. cmd: |-
  52. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  53. --tag={{ matrix_client_commet_container_image }}
  54. --build-arg GIT_HASH={{ matrix_client_commet_container_image_self_build_git_hash }}
  55. --build-arg VERSION_TAG={{ matrix_client_commet_container_image_self_build_version_tag }}
  56. --build-arg BUILD_DATE={{ ansible_date_time.epoch }}
  57. --file={{ matrix_client_commet_container_src_path }}/Dockerfile
  58. {{ matrix_client_commet_container_src_path }}
  59. changed_when: true
  60. register: matrix_client_commet_image_build_result
  61. - name: Ensure Commet global_config.json is installed
  62. ansible.builtin.template:
  63. src: "{{ role_path }}/templates/global_config.json.j2"
  64. dest: "{{ matrix_client_commet_config_path }}/global_config.json"
  65. mode: "0644"
  66. owner: "{{ matrix_user_name }}"
  67. group: "{{ matrix_group_name }}"
  68. register: matrix_client_commet_config_result
  69. - name: Ensure Commet support files are installed
  70. ansible.builtin.template:
  71. src: "{{ item.src }}"
  72. dest: "{{ matrix_client_commet_base_path }}/{{ item.name }}"
  73. mode: "0644"
  74. owner: "{{ matrix_user_name }}"
  75. group: "{{ matrix_group_name }}"
  76. with_items:
  77. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  78. - {src: "{{ role_path }}/templates/env.j2", name: "env"}
  79. register: matrix_client_commet_support_files_result
  80. - name: Ensure Commet container network is created
  81. community.general.docker_network:
  82. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  83. name: "{{ matrix_client_commet_container_network }}"
  84. driver: bridge
  85. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  86. - name: Ensure matrix-client-commet.service is installed
  87. ansible.builtin.template:
  88. src: "{{ role_path }}/templates/systemd/matrix-client-commet.service.j2"
  89. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-commet.service"
  90. mode: "0644"
  91. register: matrix_client_commet_systemd_service_result
  92. - name: Determine whether Commet needs a restart
  93. ansible.builtin.set_fact:
  94. matrix_client_commet_restart_necessary: >-
  95. {{
  96. matrix_client_commet_config_result.changed | default(false)
  97. or matrix_client_commet_support_files_result.changed | default(false)
  98. or matrix_client_commet_systemd_service_result.changed | default(false)
  99. or matrix_client_commet_image_build_result.changed | default(false)
  100. or matrix_client_commet_image_pull_result.changed | default(false)
  101. }}