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

121 строка
5.6 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_bridge_rustpush_base_path }}", when: true}
  15. - {path: "{{ matrix_bridge_rustpush_config_path }}", when: true}
  16. - {path: "{{ matrix_bridge_rustpush_data_path }}", when: true}
  17. - {path: "{{ matrix_bridge_rustpush_container_src_files_path }}", when: "{{ matrix_bridge_rustpush_container_image_self_build }}"}
  18. when: item.when | bool
  19. # 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.
  20. - name: Ensure RustPush repository ownership is correct on self-build
  21. ansible.builtin.file:
  22. path: "{{ matrix_bridge_rustpush_container_src_files_path }}"
  23. state: directory
  24. owner: "{{ matrix_user_name }}"
  25. group: "{{ matrix_group_name }}"
  26. recurse: true
  27. when: "matrix_bridge_rustpush_enabled | bool and matrix_bridge_rustpush_container_image_self_build"
  28. - name: Ensure RustPush repository is present on self-build
  29. ansible.builtin.git:
  30. repo: "{{ matrix_bridge_rustpush_container_image_self_build_repo }}"
  31. version: "{{ matrix_bridge_rustpush_container_image_self_build_repo_version }}"
  32. dest: "{{ matrix_bridge_rustpush_container_src_files_path }}"
  33. force: "yes"
  34. become: true
  35. become_user: "{{ matrix_user_name }}"
  36. register: matrix_bridge_rustpush_git_pull_results
  37. when: "matrix_bridge_rustpush_enabled | bool and matrix_bridge_rustpush_container_image_self_build"
  38. - name: Ensure RustPush Docker image is built
  39. community.docker.docker_image_build:
  40. name: "{{ matrix_bridge_rustpush_container_image }}"
  41. dockerfile: Dockerfile
  42. path: "{{ matrix_bridge_rustpush_container_src_files_path }}"
  43. pull: true
  44. rebuild: "{{ 'always' if matrix_bridge_rustpush_git_pull_results.changed | bool else 'never' }}"
  45. build_args:
  46. BUILD_VERSION: "{{ matrix_bridge_rustpush_container_image_self_build_repo_version }}"
  47. BUILD_COMMIT: "{{ matrix_bridge_rustpush_git_pull_results.after[:8] if matrix_bridge_rustpush_git_pull_results is defined and matrix_bridge_rustpush_git_pull_results.after is defined else 'unknown' }}"
  48. register: matrix_bridge_rustpush_container_image_build_result
  49. when: "matrix_bridge_rustpush_enabled | bool and matrix_bridge_rustpush_container_image_self_build | bool"
  50. - name: Ensure RustPush container image is pulled
  51. community.docker.docker_image_pull:
  52. name: "{{ matrix_bridge_rustpush_container_image }}"
  53. pull: always
  54. register: matrix_bridge_rustpush_container_image_pull_result
  55. when: "matrix_bridge_rustpush_enabled | bool and not matrix_bridge_rustpush_container_image_self_build | bool"
  56. retries: "{{ devture_playbook_help_container_retries_count }}"
  57. delay: "{{ devture_playbook_help_container_retries_delay }}"
  58. until: matrix_bridge_rustpush_container_image_pull_result is not failed
  59. ignore_errors: "{{ ansible_check_mode }}"
  60. - name: Ensure rustpush-bridge config.yaml installed
  61. ansible.builtin.copy:
  62. content: "{{ matrix_bridge_rustpush_configuration | to_nice_yaml(indent=2, width=999999) }}"
  63. dest: "{{ matrix_bridge_rustpush_config_path }}/config.yaml"
  64. mode: "0644"
  65. owner: "{{ matrix_user_name }}"
  66. group: "{{ matrix_group_name }}"
  67. register: matrix_bridge_rustpush_config_result
  68. - name: Ensure rustpush-bridge registration.yaml installed
  69. ansible.builtin.copy:
  70. content: "{{ matrix_bridge_rustpush_registration | to_nice_yaml(indent=2, width=999999) }}"
  71. dest: "{{ matrix_bridge_rustpush_config_path }}/registration.yaml"
  72. mode: "0644"
  73. owner: "{{ matrix_user_name }}"
  74. group: "{{ matrix_group_name }}"
  75. register: matrix_bridge_rustpush_registration_result
  76. - name: Ensure rustpush-bridge support files installed
  77. ansible.builtin.template:
  78. src: "{{ role_path }}/templates/{{ item }}.j2"
  79. dest: "{{ matrix_bridge_rustpush_base_path }}/{{ item }}"
  80. mode: "0640"
  81. owner: "{{ matrix_user_name }}"
  82. group: "{{ matrix_group_name }}"
  83. with_items:
  84. - labels
  85. register: matrix_bridge_rustpush_support_files_result
  86. - name: Ensure matrix-rustpush-bridge container network is created
  87. community.general.docker_network:
  88. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  89. name: "{{ matrix_bridge_rustpush_container_network }}"
  90. driver: bridge
  91. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  92. - name: Ensure matrix-rustpush-bridge.service installed
  93. ansible.builtin.template:
  94. src: "{{ role_path }}/templates/systemd/matrix-rustpush-bridge.service.j2"
  95. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service"
  96. mode: "0644"
  97. register: matrix_bridge_rustpush_systemd_service_result
  98. - name: Determine whether matrix-rustpush-bridge needs a restart
  99. ansible.builtin.set_fact:
  100. matrix_bridge_rustpush_restart_necessary: >-
  101. {{
  102. matrix_bridge_rustpush_config_result.changed | default(false)
  103. or matrix_bridge_rustpush_registration_result.changed | default(false)
  104. or matrix_bridge_rustpush_support_files_result.changed | default(false)
  105. or matrix_bridge_rustpush_systemd_service_result.changed | default(false)
  106. or matrix_bridge_rustpush_container_image_pull_result.changed | default(false)
  107. or matrix_bridge_rustpush_container_image_build_result.changed | default(false)
  108. }}