Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

79 строки
3.4 KiB

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