Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

87 righe
4.1 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_container_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_pull:
  31. name: "{{ matrix_bot_matrix_registration_bot_container_image }}"
  32. pull: always
  33. when: "not matrix_bot_matrix_registration_bot_container_image_self_build | bool"
  34. register: matrix_bot_matrix_registration_bot_container_image_pull_result
  35. retries: "{{ devture_playbook_help_container_retries_count }}"
  36. delay: "{{ devture_playbook_help_container_retries_delay }}"
  37. until: matrix_bot_matrix_registration_bot_container_image_pull_result is not failed
  38. - when: matrix_bot_matrix_registration_bot_container_image_self_build | bool
  39. block:
  40. - name: Ensure matrix-registration-bot repository is present on self-build
  41. ansible.builtin.git:
  42. repo: "{{ matrix_bot_matrix_registration_bot_container_repo }}"
  43. version: "{{ matrix_bot_matrix_registration_bot_container_repo_version }}"
  44. dest: "{{ matrix_bot_matrix_registration_bot_container_src_files_path }}"
  45. force: "yes"
  46. become: true
  47. become_user: "{{ matrix_user_name }}"
  48. register: matrix_bot_matrix_registration_bot_git_pull_results
  49. - name: Ensure matrix-registration-bot image is built
  50. community.docker.docker_image_build:
  51. name: "{{ matrix_bot_matrix_registration_bot_container_image }}"
  52. dockerfile: Dockerfile
  53. path: "{{ matrix_bot_matrix_registration_bot_container_src_files_path }}"
  54. pull: true
  55. rebuild: "{{ 'always' if matrix_bot_matrix_registration_bot_git_pull_results.changed | bool else 'never' }}"
  56. register: matrix_bot_matrix_registration_bot_container_image_build_result
  57. - name: Ensure matrix-registration-bot container network is created
  58. community.general.docker_network:
  59. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  60. name: "{{ matrix_bot_matrix_registration_bot_container_network }}"
  61. driver: bridge
  62. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  63. - name: Ensure matrix-bot-matrix-registration-bot.service installed
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2"
  66. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-matrix-registration-bot.service"
  67. mode: '0644'
  68. register: matrix_bot_matrix_registration_bot_systemd_service_result
  69. - name: Determine whether matrix-registration-bot needs a restart
  70. ansible.builtin.set_fact:
  71. matrix_bot_matrix_registration_bot_restart_necessary: >-
  72. {{
  73. matrix_bot_matrix_registration_bot_config_result.changed | default(false)
  74. or matrix_bot_matrix_registration_bot_systemd_service_result.changed | default(false)
  75. or matrix_bot_matrix_registration_bot_container_image_pull_result.changed | default(false)
  76. or matrix_bot_matrix_registration_bot_container_image_build_result.changed | default(false)
  77. }}