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

85 строки
3.5 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2025 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2025 Suguru Hirahara
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure Matrix.to path exists
  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_matrixto_base_path }}"
  15. - name: Ensure Matrix.to support files installed
  16. ansible.builtin.template:
  17. src: "{{ role_path }}/templates/{{ item }}.j2"
  18. dest: "{{ matrix_matrixto_base_path }}/{{ item }}"
  19. mode: "0640"
  20. owner: "{{ matrix_user_name }}"
  21. group: "{{ matrix_group_name }}"
  22. with_items:
  23. - env
  24. - labels
  25. register: matrix_matrixto_support_files_result
  26. - name: Ensure Matrix.to repository is present on self-build
  27. ansible.builtin.git:
  28. repo: "{{ matrix_matrixto_container_image_self_build_repo }}"
  29. version: "{{ matrix_matrixto_container_image_self_build_repo_version }}"
  30. dest: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  31. force: "yes"
  32. register: matrix_matrixto_git_pull_results
  33. - name: Ensure Matrix.to container image is built
  34. community.docker.docker_image:
  35. name: "{{ matrix_matrixto_container_image_self_build_name }}"
  36. source: build
  37. force_source: "{{ matrix_matrixto_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  38. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_matrixto_git_pull_results.changed }}"
  39. build:
  40. dockerfile: Dockerfile
  41. path: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  42. pull: true
  43. args:
  44. register: matrix_matrixto_container_image_build_result
  45. - name: Ensure Matrix.to container network is created via community.docker.docker_network
  46. when: devture_systemd_docker_base_container_network_creation_method == 'ansible-module'
  47. community.docker.docker_network:
  48. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  49. name: "{{ matrix_matrixto_container_network }}"
  50. driver: bridge
  51. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  52. - name: Ensure Matrix.to container network is created via ansible.builtin.command
  53. when: devture_systemd_docker_base_container_network_creation_method == 'command'
  54. ansible.builtin.command:
  55. cmd: >-
  56. {{ devture_systemd_docker_base_host_command_docker }} network create
  57. {% if devture_systemd_docker_base_ipv6_enabled %}--ipv6{% endif %}
  58. {{ devture_systemd_docker_base_container_networks_driver_options_string }}
  59. {{ matrix_matrixto_container_network }}
  60. register: network_creation_result
  61. changed_when: network_creation_result.rc == 0
  62. failed_when: network_creation_result.rc != 0 and 'already exists' not in network_creation_result.stderr
  63. - name: Ensure Matrix.to systemd service is present
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/systemd/matrix-matrixto.service.j2"
  66. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_matrixto_identifier }}.service"
  67. mode: "0644"
  68. register: matrix_matrixto_systemd_service_result
  69. - name: Determine whether Matrix.to needs a restart
  70. ansible.builtin.set_fact:
  71. matrix_matrixto_restart_necessary: >-
  72. {{
  73. matrix_matrixto_support_files_result.changed | default(false)
  74. or matrix_matrixto_systemd_service_result.changed | default(false)
  75. or matrix_matrixto_container_image_build_result.changed | default(false)
  76. }}