Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

130 行
5.8 KiB

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