Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

147 Zeilen
5.2 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: https://github.com/instrumentisto/coturn-docker-image.git
  25. dest: "{{ matrix_coturn_docker_src_files_path }}"
  26. version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
  27. force: "yes"
  28. when: "matrix_coturn_enabled|bool and matrix_coturn_container_image_self_build"
  29. - name: Ensure Coturn Docker image is built
  30. docker_image:
  31. name: "{{ matrix_coturn_docker_image }}"
  32. source: build
  33. build:
  34. dockerfile: Dockerfile
  35. path: "{{ matrix_coturn_docker_src_files_path }}"
  36. pull: yes
  37. when: "matrix_coturn_enabled|bool and matrix_coturn_container_image_self_build"
  38. - name: Ensure Coturn configuration path exists
  39. file:
  40. path: "{{ matrix_coturn_base_path }}"
  41. state: directory
  42. mode: 0750
  43. owner: "{{ matrix_user_username }}"
  44. group: "{{ matrix_user_groupname }}"
  45. when: matrix_coturn_enabled|bool
  46. - name: Ensure turnserver.conf installed
  47. template:
  48. src: "{{ role_path }}/templates/turnserver.conf.j2"
  49. dest: "{{ matrix_coturn_config_path }}"
  50. mode: 0644
  51. when: matrix_coturn_enabled|bool
  52. # `docker_network` doesn't work as expected when the given network
  53. # is a substring of a network that already exists.
  54. #
  55. # See our other comments in `roles/matrix-base/tasks/setup_matrix_base.yml`
  56. - name: Check existence of Coturn network in Docker
  57. shell:
  58. cmd: "docker network ls -q --filter='name=^{{ matrix_coturn_docker_network }}$'"
  59. register: matrix_coturn_result_docker_network
  60. changed_when: false
  61. when: matrix_coturn_enabled|bool
  62. check_mode: no
  63. - name: Create Coturn network in Docker
  64. shell:
  65. cmd: "docker network create --driver=bridge {{ matrix_coturn_docker_network }}"
  66. when: "matrix_coturn_enabled|bool and matrix_coturn_result_docker_network.stdout == '' and not ansible_check_mode"
  67. - name: Ensure matrix-coturn.service installed
  68. template:
  69. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  70. dest: "{{ matrix_systemd_path }}/matrix-coturn.service"
  71. mode: 0644
  72. register: matrix_coturn_systemd_service_result
  73. when: matrix_coturn_enabled|bool
  74. - name: Ensure systemd reloaded after matrix-coturn.service installation
  75. service:
  76. daemon_reload: yes
  77. when: "matrix_coturn_enabled|bool and matrix_coturn_systemd_service_result.changed"
  78. # This may be unnecessary when more long-lived certificates are used.
  79. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  80. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  81. - name: Ensure periodic reloading of matrix-coturn is configured for SSL renewal (matrix-coturn-reload)
  82. template:
  83. src: "{{ role_path }}/templates/cron.d/matrix-coturn-ssl-reload.j2"
  84. dest: /etc/cron.d/matrix-coturn-ssl-reload
  85. mode: 0644
  86. when: "matrix_coturn_enabled|bool and matrix_coturn_tls_enabled|bool"
  87. #
  88. # Tasks related to getting rid of Coturn (if it was previously enabled)
  89. #
  90. - name: Ensure matrix-coturn-ssl-reload cronjob removed
  91. file:
  92. path: /etc/cron.d/matrix-coturn-ssl-reload
  93. state: absent
  94. when: "not matrix_coturn_enabled|bool or not matrix_coturn_tls_enabled|bool"
  95. - name: Check existence of matrix-coturn service
  96. stat:
  97. path: "{{ matrix_systemd_path }}/matrix-coturn.service"
  98. register: matrix_coturn_service_stat
  99. when: "not matrix_coturn_enabled|bool"
  100. - name: Ensure matrix-coturn is stopped
  101. service:
  102. name: matrix-coturn
  103. state: stopped
  104. daemon_reload: yes
  105. register: stopping_result
  106. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  107. - name: Ensure matrix-coturn.service doesn't exist
  108. file:
  109. path: "{{ matrix_systemd_path }}/matrix-coturn.service"
  110. state: absent
  111. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  112. - name: Ensure systemd reloaded after matrix-coturn.service removal
  113. service:
  114. daemon_reload: yes
  115. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  116. - name: Ensure Matrix coturn paths don't exist
  117. file:
  118. path: "{{ matrix_coturn_base_path }}"
  119. state: absent
  120. when: "not matrix_coturn_enabled|bool"
  121. - name: Ensure coturn Docker image doesn't exist
  122. docker_image:
  123. name: "{{ matrix_coturn_docker_image }}"
  124. state: absent
  125. when: "not matrix_coturn_enabled|bool"