Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
5.0 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. register: matrix_rustpush_bridge_container_image_build_result
  46. when: "matrix_rustpush_bridge_enabled | bool and matrix_rustpush_bridge_container_image_self_build | bool"
  47. - name: Ensure RustPush container image is pulled
  48. community.docker.docker_image:
  49. name: "{{ matrix_rustpush_bridge_docker_image }}"
  50. source: pull
  51. force_source: "{{ matrix_rustpush_bridge_container_image_force_pull if matrix_rustpush_bridge_container_image_force_pull is defined else true }}"
  52. register: matrix_rustpush_bridge_container_image_pull_result
  53. when: "matrix_rustpush_bridge_enabled | bool and not matrix_rustpush_bridge_container_image_self_build | bool"
  54. ignore_errors: "{{ ansible_check_mode }}"
  55. - name: Ensure rustpush-bridge config.yaml installed
  56. ansible.builtin.copy:
  57. content: "{{ matrix_rustpush_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
  58. dest: "{{ matrix_rustpush_bridge_config_path }}/config.yaml"
  59. mode: 0644
  60. owner: "{{ matrix_user_name }}"
  61. group: "{{ matrix_group_name }}"
  62. register: matrix_rustpush_bridge_config_result
  63. - name: Ensure rustpush-bridge registration.yaml installed
  64. ansible.builtin.copy:
  65. content: "{{ matrix_rustpush_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  66. dest: "{{ matrix_rustpush_bridge_config_path }}/registration.yaml"
  67. mode: 0644
  68. owner: "{{ matrix_user_name }}"
  69. group: "{{ matrix_group_name }}"
  70. register: matrix_rustpush_bridge_registration_result
  71. - name: Ensure rustpush-bridge support files installed
  72. ansible.builtin.template:
  73. src: "{{ role_path }}/templates/{{ item }}.j2"
  74. dest: "{{ matrix_rustpush_bridge_base_path }}/{{ item }}"
  75. mode: 0640
  76. owner: "{{ matrix_user_name }}"
  77. group: "{{ matrix_group_name }}"
  78. with_items:
  79. - labels
  80. register: matrix_rustpush_bridge_support_files_result
  81. - name: Ensure matrix-rustpush-bridge container network is created
  82. community.general.docker_network:
  83. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  84. name: "{{ matrix_rustpush_bridge_container_network }}"
  85. driver: bridge
  86. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  87. - name: Ensure matrix-rustpush-bridge.service installed
  88. ansible.builtin.template:
  89. src: "{{ role_path }}/templates/systemd/matrix-rustpush-bridge.service.j2"
  90. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rustpush-bridge.service"
  91. mode: 0644
  92. register: matrix_rustpush_bridge_systemd_service_result
  93. - name: Determine whether matrix-rustpush-bridge needs a restart
  94. ansible.builtin.set_fact:
  95. matrix_rustpush_bridge_restart_necessary: >-
  96. {{
  97. matrix_rustpush_bridge_config_result.changed | default(false)
  98. or matrix_rustpush_bridge_registration_result.changed | default(false)
  99. or matrix_rustpush_bridge_support_files_result.changed | default(false)
  100. or matrix_rustpush_bridge_systemd_service_result.changed | default(false)
  101. or matrix_rustpush_bridge_container_image_pull_result.changed | default(false)
  102. or matrix_rustpush_bridge_container_image_build_result.changed | default(false)
  103. }}