Matrix Docker Ansible eploy
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

96 linhas
3.9 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. register: matrix_matrixto_git_pull_results
  43. - name: Ensure Matrix.to container image is built
  44. community.docker.docker_image_build:
  45. name: "{{ matrix_matrixto_container_image_self_build_name }}"
  46. dockerfile: Dockerfile
  47. path: "{{ matrix_matrixto_container_image_self_build_src_files_path }}"
  48. pull: true
  49. rebuild: "{{ 'always' if matrix_matrixto_git_pull_results.changed | bool else 'never' }}"
  50. register: matrix_matrixto_container_image_build_result
  51. - name: Ensure Matrix.to container network is created via community.docker.docker_network
  52. when:
  53. - devture_systemd_docker_base_container_network_creation_method == 'ansible-module'
  54. - matrix_matrixto_container_network != 'host'
  55. community.docker.docker_network:
  56. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  57. name: "{{ matrix_matrixto_container_network }}"
  58. driver: bridge
  59. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  60. - name: Ensure Matrix.to container network is created via ansible.builtin.command
  61. when:
  62. - devture_systemd_docker_base_container_network_creation_method == 'command'
  63. - matrix_matrixto_container_network != 'host'
  64. ansible.builtin.command:
  65. cmd: >-
  66. {{ devture_systemd_docker_base_host_command_docker }} network create
  67. {% if devture_systemd_docker_base_ipv6_enabled %}--ipv6{% endif %}
  68. {{ devture_systemd_docker_base_container_networks_driver_options_string }}
  69. {{ matrix_matrixto_container_network }}
  70. register: network_creation_result
  71. changed_when: network_creation_result.rc == 0
  72. failed_when: network_creation_result.rc != 0 and 'already exists' not in network_creation_result.stderr
  73. - name: Ensure Matrix.to systemd service is present
  74. ansible.builtin.template:
  75. src: "{{ role_path }}/templates/systemd/matrix-matrixto.service.j2"
  76. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_matrixto_identifier }}.service"
  77. mode: "0644"
  78. register: matrix_matrixto_systemd_service_result
  79. - name: Determine whether Matrix.to needs a restart
  80. ansible.builtin.set_fact:
  81. matrix_matrixto_restart_necessary: >-
  82. {{
  83. matrix_matrixto_support_files_result.changed | default(false)
  84. or matrix_matrixto_systemd_service_result.changed | default(false)
  85. or matrix_matrixto_container_image_build_result.changed | default(false)
  86. }}