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

107 строки
4.3 KiB

  1. ---
  2. - name: Ensure Matrix Coturn path exists
  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_coturn_docker_src_files_path }}", when: "{{ matrix_coturn_container_image_self_build }}"}
  11. when: "item.when | bool"
  12. - name: Ensure Coturn image is pulled
  13. community.docker.docker_image:
  14. name: "{{ matrix_coturn_docker_image }}"
  15. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  16. force_source: "{{ matrix_coturn_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  17. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_docker_image_force_pull }}"
  18. when: "not matrix_coturn_container_image_self_build | bool"
  19. register: result
  20. retries: "{{ devture_playbook_help_container_retries_count }}"
  21. delay: "{{ devture_playbook_help_container_retries_delay }}"
  22. until: result is not failed
  23. - when: "matrix_coturn_container_image_self_build | bool"
  24. block:
  25. - name: Ensure Coturn repository is present on self-build
  26. ansible.builtin.git:
  27. repo: "{{ matrix_coturn_container_image_self_build_repo }}"
  28. dest: "{{ matrix_coturn_docker_src_files_path }}"
  29. version: "{{ matrix_coturn_container_image_self_build_repo_version }}"
  30. force: "yes"
  31. become: true
  32. become_user: "{{ matrix_user_username }}"
  33. register: matrix_coturn_git_pull_results
  34. - name: Ensure Coturn Docker image is built
  35. community.docker.docker_image:
  36. name: "{{ matrix_coturn_docker_image }}"
  37. source: build
  38. force_source: "{{ matrix_coturn_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  39. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_git_pull_results.changed }}"
  40. build:
  41. dockerfile: "{{ matrix_coturn_container_image_self_build_repo_dockerfile_path }}"
  42. path: "{{ matrix_coturn_docker_src_files_path }}"
  43. pull: true
  44. - name: Ensure Coturn configuration path exists
  45. ansible.builtin.file:
  46. path: "{{ matrix_coturn_base_path }}"
  47. state: directory
  48. mode: 0750
  49. owner: "{{ matrix_user_username }}"
  50. group: "{{ matrix_user_groupname }}"
  51. - name: Ensure turnserver.conf installed
  52. ansible.builtin.template:
  53. src: "{{ role_path }}/templates/turnserver.conf.j2"
  54. dest: "{{ matrix_coturn_config_path }}"
  55. mode: 0644
  56. owner: "{{ matrix_user_username }}"
  57. group: "{{ matrix_user_groupname }}"
  58. - when: matrix_coturn_docker_network not in ['', 'host']
  59. name: Ensure Coturn network is created in Docker
  60. community.docker.docker_network:
  61. name: "{{ matrix_coturn_docker_network }}"
  62. driver: bridge
  63. - name: Ensure matrix-coturn.service installed
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  66. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-coturn.service"
  67. mode: 0644
  68. register: matrix_coturn_systemd_service_change_results
  69. # This may be unnecessary when more long-lived certificates are used.
  70. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  71. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  72. - name: Ensure reloading systemd units installed, if necessary
  73. ansible.builtin.template:
  74. src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
  75. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ item }}"
  76. mode: 0644
  77. register: "matrix_coturn_systemd_service_change_results"
  78. when: "matrix_coturn_tls_enabled | bool"
  79. with_items:
  80. - matrix-coturn-reload.service
  81. - matrix-coturn-reload.timer
  82. # A similar task exists in `setup_uninstall.yml`
  83. - name: Ensure reloading systemd units uninstalled, if unnecessary
  84. ansible.builtin.file:
  85. path: "{{ item }}"
  86. state: absent
  87. register: "matrix_coturn_systemd_service_change_results"
  88. when: "not matrix_coturn_tls_enabled | bool"
  89. with_items:
  90. - matrix-coturn-reload.service
  91. - matrix-coturn-reload.timer
  92. - name: Ensure systemd reloaded if systemd units changed
  93. ansible.builtin.service:
  94. daemon_reload: true
  95. when: "matrix_coturn_systemd_service_change_results.changed"