Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

101 satır
4.2 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. # A checkout owned by a different user (a uid change, an earlier clone by another user, etc.) would make the git task below fail on ownership or permissions.
  27. - name: Ensure Matrix.to repository ownership is correct on self-build
  28. ansible.builtin.file:
  29. path: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  30. state: directory
  31. owner: "{{ matrix_user_name }}"
  32. group: "{{ matrix_group_name }}"
  33. recurse: true
  34. - name: Ensure Matrix.to repository is present on self-build
  35. ansible.builtin.git:
  36. repo: "{{ matrix_matrixto_container_image_self_build_repo }}"
  37. version: "{{ matrix_matrixto_container_image_self_build_repo_version }}"
  38. dest: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  39. force: "yes"
  40. become: true
  41. become_user: "{{ matrix_user_name }}"
  42. # Keep this even though the task above normalizes ownership. Git may still see an ownership mismatch when Ansible becomes an unprivileged user (see #5065).
  43. environment:
  44. GIT_CONFIG_COUNT: "1"
  45. GIT_CONFIG_KEY_0: safe.directory
  46. GIT_CONFIG_VALUE_0: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  47. register: matrix_matrixto_git_pull_results
  48. - name: Ensure Matrix.to container image is built
  49. community.docker.docker_image_build:
  50. name: "{{ matrix_matrixto_container_image_self_build_name }}"
  51. dockerfile: Dockerfile
  52. path: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  53. pull: true
  54. rebuild: "{{ 'always' if matrix_matrixto_git_pull_results.changed | bool else 'never' }}"
  55. register: matrix_matrixto_container_image_build_result
  56. - name: Ensure Matrix.to container network is created via community.docker.docker_network
  57. when:
  58. - devture_systemd_docker_base_container_network_creation_method == 'ansible-module'
  59. - matrix_matrixto_container_network != 'host'
  60. community.docker.docker_network:
  61. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  62. name: "{{ matrix_matrixto_container_network }}"
  63. driver: bridge
  64. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  65. - name: Ensure Matrix.to container network is created via ansible.builtin.command
  66. when:
  67. - devture_systemd_docker_base_container_network_creation_method == 'command'
  68. - matrix_matrixto_container_network != 'host'
  69. ansible.builtin.command:
  70. cmd: >-
  71. {{ devture_systemd_docker_base_host_command_docker }} network create
  72. {% if devture_systemd_docker_base_ipv6_enabled %}--ipv6{% endif %}
  73. {{ devture_systemd_docker_base_container_networks_driver_options_string }}
  74. {{ matrix_matrixto_container_network }}
  75. register: network_creation_result
  76. changed_when: network_creation_result.rc == 0
  77. failed_when: network_creation_result.rc != 0 and 'already exists' not in network_creation_result.stderr
  78. - name: Ensure Matrix.to systemd service is present
  79. ansible.builtin.template:
  80. src: "{{ role_path }}/templates/systemd/matrix-matrixto.service.j2"
  81. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_matrixto_identifier }}.service"
  82. mode: "0644"
  83. register: matrix_matrixto_systemd_service_result
  84. - name: Determine whether Matrix.to needs a restart
  85. ansible.builtin.set_fact:
  86. matrix_matrixto_restart_necessary: >-
  87. {{
  88. matrix_matrixto_support_files_result.changed | default(false)
  89. or matrix_matrixto_systemd_service_result.changed | default(false)
  90. or matrix_matrixto_container_image_build_result.changed | default(false)
  91. }}