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

80 строки
3.3 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_bot_draupnir_requires_restart: false
  4. - name: Ensure matrix-bot-draupnir paths exist
  5. ansible.builtin.file:
  6. path: "{{ item.path }}"
  7. state: directory
  8. mode: 0750
  9. owner: "{{ matrix_user_username }}"
  10. group: "{{ matrix_user_groupname }}"
  11. with_items:
  12. - {path: "{{ matrix_bot_draupnir_base_path }}", when: true}
  13. - {path: "{{ matrix_bot_draupnir_config_path }}", when: true}
  14. - {path: "{{ matrix_bot_draupnir_data_path }}", when: true}
  15. - {path: "{{ matrix_bot_draupnir_docker_src_files_path }}", when: "{{ matrix_bot_draupnir_container_image_self_build }}"}
  16. when: "item.when | bool"
  17. - name: Ensure draupnir Docker image is pulled
  18. community.docker.docker_image:
  19. name: "{{ matrix_bot_draupnir_docker_image }}"
  20. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  21. force_source: "{{ matrix_bot_draupnir_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  22. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_draupnir_docker_image_force_pull }}"
  23. when: "not matrix_bot_draupnir_container_image_self_build | bool"
  24. register: result
  25. retries: "{{ devture_playbook_help_container_retries_count }}"
  26. delay: "{{ devture_playbook_help_container_retries_delay }}"
  27. until: result is not failed
  28. - name: Ensure draupnir repository is present on self-build
  29. ansible.builtin.git:
  30. repo: "{{ matrix_bot_draupnir_container_image_self_build_repo }}"
  31. dest: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  32. version: "{{ matrix_bot_draupnir_docker_image.split(':')[1] }}"
  33. force: "yes"
  34. become: true
  35. become_user: "{{ matrix_user_username }}"
  36. register: matrix_bot_draupnir_git_pull_results
  37. when: "matrix_bot_draupnir_container_image_self_build | bool"
  38. - name: Ensure draupnir Docker image is built
  39. community.docker.docker_image:
  40. name: "{{ matrix_bot_draupnir_docker_image }}"
  41. source: build
  42. force_source: "{{ matrix_bot_draupnir_git_pull_results.changed }}"
  43. build:
  44. dockerfile: Dockerfile
  45. path: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  46. pull: true
  47. when: "matrix_bot_draupnir_container_image_self_build | bool"
  48. - name: Ensure matrix-bot-draupnir config installed
  49. ansible.builtin.copy:
  50. content: "{{ matrix_bot_draupnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
  51. dest: "{{ matrix_bot_draupnir_config_path }}/production.yaml"
  52. mode: 0644
  53. owner: "{{ matrix_user_username }}"
  54. group: "{{ matrix_user_groupname }}"
  55. - name: Ensure matrix-bot-draupnir container network is created
  56. community.general.docker_network:
  57. name: "{{ matrix_bot_draupnir_container_network }}"
  58. driver: bridge
  59. - name: Ensure matrix-bot-draupnir.service installed
  60. ansible.builtin.template:
  61. src: "{{ role_path }}/templates/systemd/matrix-bot-draupnir.service.j2"
  62. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-draupnir.service"
  63. mode: 0644
  64. register: matrix_bot_draupnir_systemd_service_result
  65. - name: Ensure matrix-bot-draupnir.service restarted, if necessary
  66. ansible.builtin.service:
  67. name: "matrix-bot-draupnir.service"
  68. state: restarted
  69. daemon_reload: true
  70. when: "matrix_bot_draupnir_requires_restart | bool"