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

123 строки
4.1 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
  12. - name: Ensure Coturn configuration path exists
  13. file:
  14. path: "{{ matrix_coturn_base_path }}"
  15. state: directory
  16. mode: 0750
  17. owner: "{{ matrix_user_username }}"
  18. group: "{{ matrix_user_username }}"
  19. when: matrix_coturn_enabled|bool
  20. - name: Ensure turnserver.conf installed
  21. template:
  22. src: "{{ role_path }}/templates/turnserver.conf.j2"
  23. dest: "{{ matrix_coturn_config_path }}"
  24. mode: 0644
  25. when: matrix_coturn_enabled|bool
  26. # `docker_network` doesn't work as expected when the given network
  27. # is a substring of a network that already exists.
  28. #
  29. # See our other comments in `roles/matrix-base/tasks/setup_matrix_base.yml`
  30. - name: Check existence of Coturn network in Docker
  31. shell:
  32. cmd: "docker network ls -q --filter='name=^{{ matrix_coturn_docker_network }}$'"
  33. register: matrix_coturn_result_docker_network
  34. changed_when: false
  35. when: matrix_coturn_enabled|bool
  36. - name: Create Coturn network in Docker
  37. shell:
  38. cmd: "docker network create --driver=bridge {{ matrix_coturn_docker_network }}"
  39. when: "matrix_coturn_enabled|bool and matrix_coturn_result_docker_network.stdout == ''"
  40. - name: Ensure matrix-coturn.service installed
  41. template:
  42. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  43. dest: "/etc/systemd/system/matrix-coturn.service"
  44. mode: 0644
  45. register: matrix_coturn_systemd_service_result
  46. when: matrix_coturn_enabled|bool
  47. - name: Ensure systemd reloaded after matrix-coturn.service installation
  48. service:
  49. daemon_reload: yes
  50. when: "matrix_coturn_enabled|bool and matrix_coturn_systemd_service_result.changed"
  51. # This may be unnecessary when more long-lived certificates are used.
  52. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  53. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  54. - name: Ensure periodic reloading of matrix-coturn is configured for SSL renewal (matrix-coturn-reload)
  55. cron:
  56. user: root
  57. cron_file: matrix-coturn-ssl-reload
  58. name: matrix-coturn-ssl-reload
  59. state: present
  60. hour: "4"
  61. minute: "20"
  62. day: "*/5"
  63. job: /bin/systemctl reload matrix-coturn.service
  64. when: "matrix_coturn_enabled|bool and matrix_coturn_tls_enabled|bool"
  65. #
  66. # Tasks related to getting rid of Coturn (if it was previously enabled)
  67. #
  68. - name: Ensure matrix-coturn-ssl-reload cronjob removed
  69. cron:
  70. user: root
  71. cron_file: matrix-coturn-ssl-reload
  72. state: absent
  73. when: "not matrix_coturn_enabled|bool or not matrix_coturn_tls_enabled|bool"
  74. - name: Check existence of matrix-coturn service
  75. stat:
  76. path: "/etc/systemd/system/matrix-coturn.service"
  77. register: matrix_coturn_service_stat
  78. when: "not matrix_coturn_enabled|bool"
  79. - name: Ensure matrix-coturn is stopped
  80. service:
  81. name: matrix-coturn
  82. state: stopped
  83. daemon_reload: yes
  84. register: stopping_result
  85. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  86. - name: Ensure matrix-coturn.service doesn't exist
  87. file:
  88. path: "/etc/systemd/system/matrix-coturn.service"
  89. state: absent
  90. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  91. - name: Ensure systemd reloaded after matrix-coturn.service removal
  92. service:
  93. daemon_reload: yes
  94. when: "not matrix_coturn_enabled|bool and matrix_coturn_service_stat.stat.exists"
  95. - name: Ensure Matrix coturn paths don't exist
  96. file:
  97. path: "{{ matrix_coturn_base_path }}"
  98. state: absent
  99. when: "not matrix_coturn_enabled|bool"
  100. - name: Ensure coturn Docker image doesn't exist
  101. docker_image:
  102. name: "{{ matrix_coturn_docker_image }}"
  103. state: absent
  104. when: "not matrix_coturn_enabled|bool"