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

120 строки
5.4 KiB

  1. # SPDX-FileCopyrightText: 2026 MDAD project contributors
  2. # SPDX-FileCopyrightText: 2026 Jason LaGuidice
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure RustPush 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_rustpush_bridge_base_path }}", when: true}
  15. - {path: "{{ matrix_rustpush_bridge_config_path }}", when: true}
  16. - {path: "{{ matrix_rustpush_bridge_data_path }}", when: true}
  17. - {path: "{{ matrix_rustpush_bridge_docker_src_files_path }}", when: "{{ matrix_rustpush_bridge_container_image_self_build }}"}
  18. when: item.when | bool
  19. - name: Ensure RustPush repository is present on self-build
  20. ansible.builtin.git:
  21. repo: "{{ matrix_rustpush_bridge_container_image_self_build_repo }}"
  22. version: "{{ matrix_rustpush_bridge_container_image_self_build_repo_version }}"
  23. dest: "{{ matrix_rustpush_bridge_docker_src_files_path }}"
  24. force: "yes"
  25. become: true
  26. become_user: "{{ matrix_user_name }}"
  27. register: matrix_rustpush_bridge_git_pull_results
  28. when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build"
  29. - name: Ensure RustPush Dockerfile is installed
  30. ansible.builtin.template:
  31. src: "{{ role_path }}/templates/Dockerfile.j2"
  32. dest: "{{ matrix_rustpush_bridge_docker_src_files_path }}/Dockerfile"
  33. mode: 0640
  34. owner: "{{ matrix_user_name }}"
  35. group: "{{ matrix_group_name }}"
  36. when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool"
  37. - name: Ensure RustPush Docker image is built
  38. community.docker.docker_image:
  39. name: "{{ matrix_rustpush_bridge_docker_image }}"
  40. source: build
  41. force_source: "{{ matrix_rustpush_bridge_git_pull_results.changed if matrix_rustpush_bridge_git_pull_results is defined else true }}"
  42. build:
  43. dockerfile: Dockerfile
  44. path: "{{ matrix_rustpush_bridge_docker_src_files_path }}"
  45. pull: true
  46. args:
  47. BUILD_VERSION: "{{ matrix_rustpush_bridge_container_image_self_build_repo_version }}"
  48. BUILD_COMMIT: "{{ matrix_rustpush_bridge_git_pull_results.after[:8] if matrix_rustpush_bridge_git_pull_results is defined and matrix_rustpush_bridge_git_pull_results.after is defined else 'unknown' }}"
  49. register: matrix_rustpush_bridge_container_image_build_result
  50. when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool"
  51. - name: Ensure RustPush container image is pulled
  52. community.docker.docker_image:
  53. name: "{{ matrix_rustpush_bridge_docker_image }}"
  54. source: pull
  55. force_source: "{{ matrix_rustpush_bridge_container_image_force_pull if matrix_rustpush_bridge_container_image_force_pull is defined else true }}"
  56. register: matrix_rustpush_bridge_container_image_pull_result
  57. when: "matrix_rustpush_bridge_enabled | bool and not matrix_rustpush_bridge_container_image_self_build | bool"
  58. ignore_errors: "{{ ansible_check_mode }}"
  59. - name: Ensure rustpush-bridge config.yaml installed
  60. ansible.builtin.copy:
  61. content: "{{ matrix_rustpush_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
  62. dest: "{{ matrix_rustpush_bridge_config_path }}/config.yaml"
  63. mode: 0644
  64. owner: "{{ matrix_user_name }}"
  65. group: "{{ matrix_group_name }}"
  66. register: matrix_rustpush_bridge_config_result
  67. - name: Ensure rustpush-bridge registration.yaml installed
  68. ansible.builtin.copy:
  69. content: "{{ matrix_rustpush_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  70. dest: "{{ matrix_rustpush_bridge_config_path }}/registration.yaml"
  71. mode: 0644
  72. owner: "{{ matrix_user_name }}"
  73. group: "{{ matrix_group_name }}"
  74. register: matrix_rustpush_bridge_registration_result
  75. - name: Ensure rustpush-bridge support files installed
  76. ansible.builtin.template:
  77. src: "{{ role_path }}/templates/{{ item }}.j2"
  78. dest: "{{ matrix_rustpush_bridge_base_path }}/{{ item }}"
  79. mode: 0640
  80. owner: "{{ matrix_user_name }}"
  81. group: "{{ matrix_group_name }}"
  82. with_items:
  83. - labels
  84. register: matrix_rustpush_bridge_support_files_result
  85. - name: Ensure matrix-rustpush-bridge container network is created
  86. community.general.docker_network:
  87. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  88. name: "{{ matrix_rustpush_bridge_container_network }}"
  89. driver: bridge
  90. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  91. - name: Ensure matrix-rustpush-bridge.service installed
  92. ansible.builtin.template:
  93. src: "{{ role_path }}/templates/systemd/matrix-rustpush-bridge.service.j2"
  94. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service"
  95. mode: 0644
  96. register: matrix_rustpush_bridge_systemd_service_result
  97. - name: Determine whether matrix-rustpush-bridge needs a restart
  98. ansible.builtin.set_fact:
  99. matrix_rustpush_bridge_restart_necessary: >-
  100. {{
  101. matrix_rustpush_bridge_config_result.changed | default(false)
  102. or matrix_rustpush_bridge_registration_result.changed | default(false)
  103. or matrix_rustpush_bridge_support_files_result.changed | default(false)
  104. or matrix_rustpush_bridge_systemd_service_result.changed | default(false)
  105. or matrix_rustpush_bridge_container_image_pull_result.changed | default(false)
  106. or matrix_rustpush_bridge_container_image_build_result.changed | default(false)
  107. }}