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.
 
 

76 satır
3.2 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2024 David Mehren
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure chatgpt paths exist
  7. ansible.builtin.file:
  8. path: "{{ item.path }}"
  9. state: directory
  10. mode: 0750
  11. owner: "{{ matrix_user_name }}"
  12. group: "{{ matrix_group_name }}"
  13. with_items:
  14. - {path: "{{ matrix_bot_chatgpt_config_path }}", when: true}
  15. - {path: "{{ matrix_bot_chatgpt_data_path }}", when: true}
  16. - {path: "{{ matrix_bot_chatgpt_container_src_path }}", when: matrix_bot_chatgpt_container_image_self_build}
  17. when: "item.when | bool"
  18. - name: Ensure chatgpt environment variables file created
  19. ansible.builtin.template:
  20. src: "{{ role_path }}/templates/env.j2"
  21. dest: "{{ matrix_bot_chatgpt_config_path }}/env"
  22. owner: "{{ matrix_user_name }}"
  23. group: "{{ matrix_group_name }}"
  24. mode: 0640
  25. - name: Ensure chatgpt container image is pulled
  26. community.docker.docker_image:
  27. name: "{{ matrix_bot_chatgpt_container_image }}"
  28. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  29. force_source: "{{ matrix_bot_chatgpt_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  30. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_chatgpt_container_image_force_pull }}"
  31. when: "not matrix_bot_chatgpt_container_image_self_build | bool"
  32. register: result
  33. retries: "{{ devture_playbook_help_container_retries_count }}"
  34. delay: "{{ devture_playbook_help_container_retries_delay }}"
  35. until: result is not failed
  36. - when: matrix_bot_chatgpt_container_image_self_build | bool
  37. block:
  38. - name: Ensure chatgpt repository is present on self-build
  39. ansible.builtin.git:
  40. repo: "{{ matrix_bot_chatgpt_container_image_self_build_repo }}"
  41. version: "{{ matrix_bot_chatgpt_container_image_self_build_repo_version }}"
  42. dest: "{{ matrix_bot_chatgpt_container_src_path }}"
  43. force: "yes"
  44. become: true
  45. become_user: "{{ matrix_user_name }}"
  46. register: matrix_bot_chatgpt_git_pull_results
  47. - name: Ensure chatgpt container image is built
  48. community.docker.docker_image:
  49. name: "{{ matrix_bot_chatgpt_container_image }}"
  50. source: build
  51. force_source: "{{ matrix_bot_chatgpt_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  52. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_chatgpt_git_pull_results.changed }}"
  53. build:
  54. dockerfile: Dockerfile
  55. path: "{{ matrix_bot_chatgpt_container_src_path }}"
  56. pull: true
  57. - name: Ensure chatgpt container network is created
  58. community.general.docker_network:
  59. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  60. name: "{{ matrix_bot_chatgpt_container_network }}"
  61. driver: bridge
  62. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  63. - name: Ensure matrix-bot-chatgpt.service installed
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/systemd/matrix-bot-chatgpt.service.j2"
  66. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-chatgpt.service"
  67. mode: 0644