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

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