Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

142 satır
4.8 KiB

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