Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

131 wiersze
5.8 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: >-
  62. {{
  63. matrix_rustpush_bridge_configuration
  64. | combine({
  65. 'network': {
  66. 'displayname_template': matrix_rustpush_bridge_network_displayname_template_effective,
  67. },
  68. }, recursive=True)
  69. | to_nice_yaml(indent=2, width=999999)
  70. }}
  71. dest: "{{ matrix_rustpush_bridge_config_path }}/config.yaml"
  72. mode: 0644
  73. owner: "{{ matrix_user_name }}"
  74. group: "{{ matrix_group_name }}"
  75. vars:
  76. matrix_rustpush_bridge_network_displayname_template_effective: "{{ (matrix_rustpush_bridge_configuration.network | default({}, true)).displayname_template | default(matrix_rustpush_bridge_network_displayname_template) }}"
  77. register: matrix_rustpush_bridge_config_result
  78. - name: Ensure rustpush-bridge registration.yaml installed
  79. ansible.builtin.copy:
  80. content: "{{ matrix_rustpush_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  81. dest: "{{ matrix_rustpush_bridge_config_path }}/registration.yaml"
  82. mode: 0644
  83. owner: "{{ matrix_user_name }}"
  84. group: "{{ matrix_group_name }}"
  85. register: matrix_rustpush_bridge_registration_result
  86. - name: Ensure rustpush-bridge support files installed
  87. ansible.builtin.template:
  88. src: "{{ role_path }}/templates/{{ item }}.j2"
  89. dest: "{{ matrix_rustpush_bridge_base_path }}/{{ item }}"
  90. mode: 0640
  91. owner: "{{ matrix_user_name }}"
  92. group: "{{ matrix_group_name }}"
  93. with_items:
  94. - labels
  95. register: matrix_rustpush_bridge_support_files_result
  96. - name: Ensure matrix-rustpush-bridge container network is created
  97. community.general.docker_network:
  98. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  99. name: "{{ matrix_rustpush_bridge_container_network }}"
  100. driver: bridge
  101. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  102. - name: Ensure matrix-rustpush-bridge.service installed
  103. ansible.builtin.template:
  104. src: "{{ role_path }}/templates/systemd/matrix-rustpush-bridge.service.j2"
  105. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service"
  106. mode: 0644
  107. register: matrix_rustpush_bridge_systemd_service_result
  108. - name: Determine whether matrix-rustpush-bridge needs a restart
  109. ansible.builtin.set_fact:
  110. matrix_rustpush_bridge_restart_necessary: >-
  111. {{
  112. matrix_rustpush_bridge_config_result.changed | default(false)
  113. or matrix_rustpush_bridge_registration_result.changed | default(false)
  114. or matrix_rustpush_bridge_support_files_result.changed | default(false)
  115. or matrix_rustpush_bridge_systemd_service_result.changed | default(false)
  116. or matrix_rustpush_bridge_container_image_pull_result.changed | default(false)
  117. or matrix_rustpush_bridge_container_image_build_result.changed | default(false)
  118. }}