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

89 строки
3.2 KiB

  1. ---
  2. - name: Ensure Matrix Coturn path exists
  3. 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. 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. - name: Ensure Coturn repository is present on self-build
  20. git:
  21. repo: "{{ matrix_coturn_container_image_self_build_repo }}"
  22. dest: "{{ matrix_coturn_docker_src_files_path }}"
  23. version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
  24. force: "yes"
  25. register: matrix_coturn_git_pull_results
  26. when: "matrix_coturn_container_image_self_build|bool"
  27. - name: Ensure Coturn Docker image is built
  28. docker_image:
  29. name: "{{ matrix_coturn_docker_image }}"
  30. source: build
  31. force_source: "{{ matrix_coturn_git_pull_results.changed }}"
  32. build:
  33. dockerfile: Dockerfile
  34. path: "{{ matrix_coturn_docker_src_files_path }}"
  35. pull: yes
  36. when: "matrix_coturn_container_image_self_build|bool"
  37. - name: Ensure Coturn configuration path exists
  38. file:
  39. path: "{{ matrix_coturn_base_path }}"
  40. state: directory
  41. mode: 0750
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_groupname }}"
  44. - name: Ensure turnserver.conf installed
  45. template:
  46. src: "{{ role_path }}/templates/turnserver.conf.j2"
  47. dest: "{{ matrix_coturn_config_path }}"
  48. mode: 0644
  49. - name: Ensure Coturn network is created in Docker
  50. docker_network:
  51. name: "{{ matrix_coturn_docker_network }}"
  52. driver: bridge
  53. - name: Ensure matrix-coturn.service installed
  54. template:
  55. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  56. dest: "{{ matrix_systemd_path }}/matrix-coturn.service"
  57. mode: 0644
  58. register: matrix_coturn_systemd_service_result
  59. - name: Ensure systemd reloaded after matrix-coturn.service installation
  60. service:
  61. daemon_reload: yes
  62. when: "matrix_coturn_systemd_service_result.changed"
  63. # This may be unnecessary when more long-lived certificates are used.
  64. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  65. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  66. - name: Ensure periodic reloading of matrix-coturn is configured for SSL renewal (matrix-coturn-reload)
  67. template:
  68. src: "{{ role_path }}/templates/cron.d/matrix-coturn-ssl-reload.j2"
  69. dest: /etc/cron.d/matrix-coturn-ssl-reload
  70. mode: 0644
  71. when: "matrix_coturn_tls_enabled|bool"
  72. # A similar task exists in `setup_uninstall.yml`
  73. - name: Ensure matrix-coturn-ssl-reload cronjob removed
  74. file:
  75. path: /etc/cron.d/matrix-coturn-ssl-reload
  76. state: absent
  77. when: "not matrix_coturn_tls_enabled|bool"