Matrix Docker Ansible eploy
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

90 lines
4.5 KiB

  1. # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr
  2. # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev
  3. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  4. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  5. # SPDX-FileCopyrightText: 2024 David Mehren
  6. #
  7. # SPDX-License-Identifier: AGPL-3.0-or-later
  8. ---
  9. - name: Ensure matrix-registration-bot paths exist
  10. ansible.builtin.file:
  11. path: "{{ item.path }}"
  12. state: directory
  13. mode: '0750'
  14. owner: "{{ matrix_user_name }}"
  15. group: "{{ matrix_group_name }}"
  16. with_items:
  17. - {path: "{{ matrix_bot_matrix_registration_bot_config_path }}", when: true}
  18. - {path: "{{ matrix_bot_matrix_registration_bot_data_path }}", when: true}
  19. - {path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}", when: "{{ matrix_bot_matrix_registration_bot_container_image_self_build }}"}
  20. when: "item.when | bool"
  21. - name: Ensure matrix-registration-bot configuration file created
  22. ansible.builtin.template:
  23. src: "{{ role_path }}/templates/config.yaml.j2"
  24. dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/config.yaml"
  25. owner: "{{ matrix_user_name }}"
  26. group: "{{ matrix_group_name }}"
  27. mode: '0640'
  28. register: matrix_bot_matrix_registration_bot_config_result
  29. - name: Ensure matrix-registration-bot image is pulled
  30. community.docker.docker_image:
  31. name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
  32. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  33. force_source: "{{ matrix_bot_matrix_registration_bot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  34. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_matrix_registration_bot_docker_image_force_pull }}"
  35. when: "not matrix_bot_matrix_registration_bot_container_image_self_build | bool"
  36. register: matrix_bot_matrix_registration_bot_container_image_pull_result
  37. retries: "{{ devture_playbook_help_container_retries_count }}"
  38. delay: "{{ devture_playbook_help_container_retries_delay }}"
  39. until: matrix_bot_matrix_registration_bot_container_image_pull_result is not failed
  40. - when: matrix_bot_matrix_registration_bot_container_image_self_build | bool
  41. block:
  42. - name: Ensure matrix-registration-bot repository is present on self-build
  43. ansible.builtin.git:
  44. repo: "{{ matrix_bot_matrix_registration_bot_docker_repo }}"
  45. version: "{{ matrix_bot_matrix_registration_bot_docker_repo_version }}"
  46. dest: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
  47. force: "yes"
  48. become: true
  49. become_user: "{{ matrix_user_name }}"
  50. register: matrix_bot_matrix_registration_bot_git_pull_results
  51. - name: Ensure matrix-registration-bot image is built
  52. community.docker.docker_image:
  53. name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
  54. source: build
  55. force_source: "{{ matrix_bot_matrix_registration_bot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  56. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_matrix_registration_bot_git_pull_results.changed }}"
  57. build:
  58. dockerfile: Dockerfile
  59. path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
  60. pull: true
  61. - name: Ensure matrix-registration-bot container network is created
  62. community.general.docker_network:
  63. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  64. name: "{{ matrix_bot_matrix_registration_bot_container_network }}"
  65. driver: bridge
  66. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  67. - name: Ensure matrix-bot-matrix-registration-bot.service installed
  68. ansible.builtin.template:
  69. src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2"
  70. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-matrix-registration-bot.service"
  71. mode: '0644'
  72. register: matrix_bot_matrix_registration_bot_systemd_service_result
  73. - name: Determine whether matrix-registration-bot needs a restart
  74. ansible.builtin.set_fact:
  75. matrix_bot_matrix_registration_bot_restart_necessary: >-
  76. {{
  77. matrix_bot_matrix_registration_bot_config_result.changed | default(false)
  78. or matrix_bot_matrix_registration_bot_systemd_service_result.changed | default(false)
  79. or matrix_bot_matrix_registration_bot_container_image_pull_result.changed | default(false)
  80. }}