Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

100 satır
4.0 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2024 MDAD project contributors
  2. # SPDX-FileCopyrightText: 2024 David Mehren
  3. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  4. # SPDX-FileCopyrightText: 2024 Suguru Hirahara
  5. #
  6. # SPDX-License-Identifier: AGPL-3.0-or-later
  7. ---
  8. - ansible.builtin.set_fact:
  9. matrix_bot_draupnir_requires_restart: false
  10. - name: Ensure matrix-bot-draupnir paths exist
  11. ansible.builtin.file:
  12. path: "{{ item.path }}"
  13. state: directory
  14. mode: 0750
  15. owner: "{{ matrix_user_username }}"
  16. group: "{{ matrix_user_groupname }}"
  17. with_items:
  18. - {path: "{{ matrix_bot_draupnir_base_path }}", when: true}
  19. - {path: "{{ matrix_bot_draupnir_config_path }}", when: true}
  20. - {path: "{{ matrix_bot_draupnir_data_path }}", when: true}
  21. - {path: "{{ matrix_bot_draupnir_docker_src_files_path }}", when: "{{ matrix_bot_draupnir_container_image_self_build }}"}
  22. when: "item.when | bool"
  23. - name: Ensure matrix-bot-draupnir support files installed
  24. ansible.builtin.template:
  25. src: "{{ item.src }}"
  26. dest: "{{ item.dest }}"
  27. owner: "{{ matrix_user_username }}"
  28. group: "{{ matrix_user_groupname }}"
  29. mode: 0644
  30. with_items:
  31. - src: "{{ role_path }}/templates/labels.j2"
  32. dest: "{{ matrix_bot_draupnir_base_path }}/labels"
  33. - name: Ensure Draupnir Docker image is pulled
  34. community.docker.docker_image:
  35. name: "{{ matrix_bot_draupnir_docker_image }}"
  36. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  37. force_source: "{{ matrix_bot_draupnir_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  38. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_draupnir_docker_image_force_pull }}"
  39. when: "not matrix_bot_draupnir_container_image_self_build | bool"
  40. register: result
  41. retries: "{{ devture_playbook_help_container_retries_count }}"
  42. delay: "{{ devture_playbook_help_container_retries_delay }}"
  43. until: result is not failed
  44. - name: Ensure Draupnir repository is present on self-build
  45. ansible.builtin.git:
  46. repo: "{{ matrix_bot_draupnir_container_image_self_build_repo }}"
  47. dest: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  48. version: "{{ matrix_bot_draupnir_docker_image.split(':')[1] }}"
  49. force: "yes"
  50. become: true
  51. become_user: "{{ matrix_user_username }}"
  52. register: matrix_bot_draupnir_git_pull_results
  53. when: "matrix_bot_draupnir_container_image_self_build | bool"
  54. - name: Ensure Draupnir Docker image is built
  55. community.docker.docker_image:
  56. name: "{{ matrix_bot_draupnir_docker_image }}"
  57. source: build
  58. force_source: "{{ matrix_bot_draupnir_git_pull_results.changed }}"
  59. build:
  60. dockerfile: Dockerfile
  61. path: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  62. pull: true
  63. when: "matrix_bot_draupnir_container_image_self_build | bool"
  64. - name: Ensure matrix-bot-draupnir config installed
  65. ansible.builtin.copy:
  66. content: "{{ matrix_bot_draupnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
  67. dest: "{{ matrix_bot_draupnir_config_path }}/production.yaml"
  68. mode: 0644
  69. owner: "{{ matrix_user_username }}"
  70. group: "{{ matrix_user_groupname }}"
  71. - name: Ensure matrix-bot-draupnir container network is created
  72. community.general.docker_network:
  73. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  74. name: "{{ matrix_bot_draupnir_container_network }}"
  75. driver: bridge
  76. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  77. - name: Ensure matrix-bot-draupnir.service installed
  78. ansible.builtin.template:
  79. src: "{{ role_path }}/templates/systemd/matrix-bot-draupnir.service.j2"
  80. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-draupnir.service"
  81. mode: 0644
  82. register: matrix_bot_draupnir_systemd_service_result
  83. - name: Ensure matrix-bot-draupnir.service restarted, if necessary
  84. ansible.builtin.service:
  85. name: "matrix-bot-draupnir.service"
  86. state: restarted
  87. daemon_reload: true
  88. when: "matrix_bot_draupnir_requires_restart | bool"