Matrix Docker Ansible eploy
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

83 rindas
3.5 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure baibot paths exist
  6. ansible.builtin.file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - {path: "{{ matrix_bot_baibot_base_path }}", when: true}
  14. - {path: "{{ matrix_bot_baibot_config_path }}", when: true}
  15. - {path: "{{ matrix_bot_baibot_data_path }}", when: true}
  16. - {path: "{{ matrix_bot_baibot_container_src_files_path }}", when: "{{ matrix_bot_baibot_container_image_self_build }}"}
  17. when: "item.when | bool"
  18. - name: Ensure baibot configuration installed
  19. ansible.builtin.copy:
  20. content: "{{ matrix_bot_baibot_configuration | to_nice_yaml(indent=2, width=999999) }}"
  21. dest: "{{ matrix_bot_baibot_config_path }}/config.yml"
  22. mode: 0644
  23. owner: "{{ matrix_user_username }}"
  24. group: "{{ matrix_user_groupname }}"
  25. - name: Ensure baibot environment variables file created
  26. ansible.builtin.template:
  27. src: "{{ role_path }}/templates/env.j2"
  28. dest: "{{ matrix_bot_baibot_config_path }}/env"
  29. owner: "{{ matrix_user_username }}"
  30. group: "{{ matrix_user_groupname }}"
  31. mode: 0640
  32. - name: Ensure baibot container image is pulled
  33. community.docker.docker_image:
  34. name: "{{ matrix_bot_baibot_container_image }}"
  35. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  36. force_source: "{{ matrix_bot_baibot_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  37. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_baibot_container_image_force_pull }}"
  38. when: "not matrix_bot_baibot_container_image_self_build | bool"
  39. register: result
  40. retries: "{{ devture_playbook_help_container_retries_count }}"
  41. delay: "{{ devture_playbook_help_container_retries_delay }}"
  42. until: result is not failed
  43. - when: "matrix_bot_baibot_container_image_self_build | bool"
  44. block:
  45. - name: Ensure baibot repository is present on self-build
  46. ansible.builtin.git:
  47. repo: "{{ matrix_bot_baibot_container_repo }}"
  48. version: "{{ matrix_bot_baibot_container_repo_version }}"
  49. dest: "{{ matrix_bot_baibot_container_src_files_path }}"
  50. force: "yes"
  51. become: true
  52. become_user: "{{ matrix_user_username }}"
  53. register: matrix_bot_baibot_git_pull_results
  54. - name: Ensure baibot container image is built
  55. community.docker.docker_image:
  56. name: "{{ matrix_bot_baibot_container_image }}"
  57. source: build
  58. force_source: "{{ matrix_bot_baibot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  59. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_baibot_git_pull_results.changed }}"
  60. build:
  61. dockerfile: Dockerfile
  62. path: "{{ matrix_bot_baibot_container_src_files_path }}"
  63. pull: true
  64. - name: Ensure baibot container network is created
  65. community.general.docker_network:
  66. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  67. name: "{{ matrix_bot_baibot_container_network }}"
  68. driver: bridge
  69. - name: Ensure matrix-bot-baibot.service installed
  70. ansible.builtin.template:
  71. src: "{{ role_path }}/templates/systemd/matrix-bot-baibot.service.j2"
  72. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-baibot.service"
  73. mode: 0644