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.
 
 

95 líneas
3.8 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. register: matrix_bot_baibot_config_result
  27. - name: Ensure baibot environment variables file created
  28. ansible.builtin.template:
  29. src: "{{ role_path }}/templates/env.j2"
  30. dest: "{{ matrix_bot_baibot_config_path }}/env"
  31. owner: "{{ matrix_user_name }}"
  32. group: "{{ matrix_group_name }}"
  33. mode: '0640'
  34. register: matrix_bot_baibot_env_result
  35. - name: Ensure baibot container image is pulled
  36. community.docker.docker_image_pull:
  37. name: "{{ matrix_bot_baibot_container_image }}"
  38. pull: always
  39. when: "not matrix_bot_baibot_container_image_self_build | bool"
  40. register: matrix_bot_baibot_container_image_pull_result
  41. retries: "{{ devture_playbook_help_container_retries_count }}"
  42. delay: "{{ devture_playbook_help_container_retries_delay }}"
  43. until: matrix_bot_baibot_container_image_pull_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_build:
  57. name: "{{ matrix_bot_baibot_container_image }}"
  58. dockerfile: Dockerfile
  59. path: "{{ matrix_bot_baibot_container_src_files_path }}"
  60. pull: true
  61. rebuild: "{{ 'always' if matrix_bot_baibot_git_pull_results.changed | bool else 'never' }}"
  62. register: matrix_bot_baibot_container_image_build_result
  63. - name: Ensure baibot container network is created
  64. community.general.docker_network:
  65. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  66. name: "{{ matrix_bot_baibot_container_network }}"
  67. driver: bridge
  68. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  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'
  74. register: matrix_bot_baibot_systemd_service_result
  75. - name: Determine whether baibot needs a restart
  76. ansible.builtin.set_fact:
  77. matrix_bot_baibot_restart_necessary: >-
  78. {{
  79. matrix_bot_baibot_config_result.changed | default(false)
  80. or matrix_bot_baibot_env_result.changed | default(false)
  81. or matrix_bot_baibot_systemd_service_result.changed | default(false)
  82. or matrix_bot_baibot_container_image_pull_result.changed | default(false)
  83. or matrix_bot_baibot_container_image_build_result.changed | default(false)
  84. }}