Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

85 líneas
3.6 KiB

  1. # SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure baibot 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_baibot_base_path }}", when: true}
  15. - {path: "{{ matrix_bot_baibot_config_path }}", when: true}
  16. - {path: "{{ matrix_bot_baibot_data_path }}", when: true}
  17. - {path: "{{ matrix_bot_baibot_container_src_files_path }}", when: "{{ matrix_bot_baibot_container_image_self_build }}"}
  18. when: "item.when | bool"
  19. - name: Ensure baibot configuration installed
  20. ansible.builtin.copy:
  21. content: "{{ matrix_bot_baibot_configuration | to_nice_yaml(indent=2, width=999999) }}"
  22. dest: "{{ matrix_bot_baibot_config_path }}/config.yml"
  23. mode: 0644
  24. owner: "{{ matrix_user_name }}"
  25. group: "{{ matrix_group_name }}"
  26. - name: Ensure baibot environment variables file created
  27. ansible.builtin.template:
  28. src: "{{ role_path }}/templates/env.j2"
  29. dest: "{{ matrix_bot_baibot_config_path }}/env"
  30. owner: "{{ matrix_user_name }}"
  31. group: "{{ matrix_group_name }}"
  32. mode: 0640
  33. - name: Ensure baibot container image is pulled
  34. community.docker.docker_image:
  35. name: "{{ matrix_bot_baibot_container_image }}"
  36. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  37. force_source: "{{ matrix_bot_baibot_container_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_baibot_container_image_force_pull }}"
  39. when: "not matrix_bot_baibot_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. - when: "matrix_bot_baibot_container_image_self_build | bool"
  45. block:
  46. - name: Ensure baibot repository is present on self-build
  47. ansible.builtin.git:
  48. repo: "{{ matrix_bot_baibot_container_repo }}"
  49. version: "{{ matrix_bot_baibot_container_repo_version }}"
  50. dest: "{{ matrix_bot_baibot_container_src_files_path }}"
  51. force: "yes"
  52. become: true
  53. become_user: "{{ matrix_user_name }}"
  54. register: matrix_bot_baibot_git_pull_results
  55. - name: Ensure baibot container image is built
  56. community.docker.docker_image:
  57. name: "{{ matrix_bot_baibot_container_image }}"
  58. source: build
  59. force_source: "{{ matrix_bot_baibot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  60. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_baibot_git_pull_results.changed }}"
  61. build:
  62. dockerfile: Dockerfile
  63. path: "{{ matrix_bot_baibot_container_src_files_path }}"
  64. pull: true
  65. - name: Ensure baibot container network is created
  66. community.general.docker_network:
  67. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  68. name: "{{ matrix_bot_baibot_container_network }}"
  69. driver: bridge
  70. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  71. - name: Ensure matrix-bot-baibot.service installed
  72. ansible.builtin.template:
  73. src: "{{ role_path }}/templates/systemd/matrix-bot-baibot.service.j2"
  74. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-baibot.service"
  75. mode: 0644