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

138 строки
4.7 KiB

  1. ---
  2. #
  3. # Tasks related to setting up Coturn
  4. #
  5. - name: Ensure Matrix Coturn path exists
  6. file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - { path: "{{ matrix_coturn_docker_src_files_path }}", when: "{{ matrix_coturn_container_image_self_build }}"}
  14. when: matrix_coturn_enabled|bool and item.when
  15. - name: Ensure Coturn image is pulled
  16. docker_image:
  17. name: "{{ matrix_coturn_docker_image }}"
  18. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  19. force_source: "{{ matrix_coturn_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  20. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_docker_image_force_pull }}"
  21. when: matrix_coturn_enabled|bool and not matrix_coturn_container_image_self_build
  22. - name: Ensure Coturn repository is present on self-build
  23. git:
  24. repo: "{{ matrix_coturn_container_image_self_build_repo }}"
  25. dest: "{{ matrix_coturn_docker_src_files_path }}"
  26. version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
  27. force: "yes"
  28. register: matrix_coturn_git_pull_results
  29. when: "matrix_coturn_enabled|bool and matrix_coturn_container_image_self_build"
  30. - name: Ensure Coturn Docker image is built
  31. docker_image:
  32. name: "{{ matrix_coturn_docker_image }}"
  33. source: build
  34. force_source: "{{ matrix_coturn_git_pull_results.changed }}"
  35. build:
  36. dockerfile: Dockerfile
  37. path: "{{ matrix_coturn_docker_src_files_path }}"
  38. pull: yes
  39. when: "matrix_coturn_enabled|bool and matrix_coturn_container_image_self_build|bool"
  40. - name: Ensure Coturn configuration path exists
  41. file:
  42. path: "{{ matrix_coturn_base_path }}"
  43. state: directory
  44. mode: 0750
  45. owner: "{{ matrix_user_username }}"
  46. group: "{{ matrix_user_groupname }}"
  47. when: matrix_coturn_enabled|bool
  48. - name: Ensure turnserver.conf installed
  49. template:
  50. src: "{{ role_path }}/templates/turnserver.conf.j2"
  51. dest: "{{ matrix_coturn_config_path }}"
  52. mode: 0644
  53. when: matrix_coturn_enabled|bool
  54. - name: Ensure Coturn network is created in Docker
  55. docker_network:
  56. name: "{{ matrix_coturn_docker_network }}"
  57. driver: bridge
  58. when: matrix_coturn_enabled|bool
  59. - name: Ensure matrix-coturn.service installed
  60. template:
  61. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  62. dest: "{{ matrix_systemd_path }}/matrix-coturn.service"
  63. mode: 0644
  64. register: matrix_coturn_systemd_service_result
  65. when: matrix_coturn_enabled|bool
  66. - name: Ensure systemd reloaded after matrix-coturn.service installation
  67. service:
  68. daemon_reload: yes
  69. when: "matrix_coturn_enabled|bool and matrix_coturn_systemd_service_result.changed"
  70. # This may be unnecessary when more long-lived certificates are used.
  71. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  72. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  73. - name: Ensure periodic reloading of matrix-coturn is configured for SSL renewal (matrix-coturn-reload)
  74. template:
  75. src: "{{ role_path }}/templates/cron.d/matrix-coturn-ssl-reload.j2"
  76. dest: /etc/cron.d/matrix-coturn-ssl-reload
  77. mode: 0644
  78. when: "matrix_coturn_enabled|bool and matrix_coturn_tls_enabled|bool"
  79. #
  80. # Tasks related to getting rid of Coturn (if it was previously enabled)
  81. #
  82. - name: Ensure matrix-coturn-ssl-reload cronjob removed
  83. file:
  84. path: /etc/cron.d/matrix-coturn-ssl-reload
  85. state: absent
  86. when: "not matrix_coturn_enabled|bool or not matrix_coturn_tls_enabled|bool"
  87. - name: Check existence of matrix-coturn service
  88. stat:
  89. path: "{{ matrix_systemd_path }}/matrix-coturn.service"
  90. register: matrix_coturn_service_stat
  91. when: "not matrix_coturn_enabled|bool"
  92. - name: Ensure matrix-coturn is stopped
  93. service:
  94. name: matrix-coturn
  95. state: stopped
  96. daemon_reload: yes
  97. register: stopping_result
  98. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  99. - name: Ensure matrix-coturn.service doesn't exist
  100. file:
  101. path: "{{ matrix_systemd_path }}/matrix-coturn.service"
  102. state: absent
  103. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  104. - name: Ensure systemd reloaded after matrix-coturn.service removal
  105. service:
  106. daemon_reload: yes
  107. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  108. - name: Ensure Matrix coturn paths don't exist
  109. file:
  110. path: "{{ matrix_coturn_base_path }}"
  111. state: absent
  112. when: "not matrix_coturn_enabled|bool"
  113. - name: Ensure coturn Docker image doesn't exist
  114. docker_image:
  115. name: "{{ matrix_coturn_docker_image }}"
  116. state: absent
  117. when: "not matrix_coturn_enabled|bool"