Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

112 righe
4.2 KiB

  1. ---
  2. # This is a cleanup/migration task. It can be removed some time in the future.
  3. - name: (Migration) Remove deprecated cronjob
  4. file:
  5. path: "{{ matrix_cron_path }}/matrix-coturn-ssl-reload"
  6. state: absent
  7. - name: Ensure Matrix Coturn path exists
  8. file:
  9. path: "{{ item.path }}"
  10. state: directory
  11. mode: 0750
  12. owner: "{{ matrix_user_username }}"
  13. group: "{{ matrix_user_groupname }}"
  14. with_items:
  15. - {path: "{{ matrix_coturn_docker_src_files_path }}", when: "{{ matrix_coturn_container_image_self_build }}"}
  16. when: "item.when|bool"
  17. - name: Ensure Coturn image is pulled
  18. docker_image:
  19. name: "{{ matrix_coturn_docker_image }}"
  20. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  21. force_source: "{{ matrix_coturn_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  22. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_docker_image_force_pull }}"
  23. when: "not matrix_coturn_container_image_self_build|bool"
  24. register: result
  25. retries: "{{ matrix_container_retries_count }}"
  26. delay: "{{ matrix_container_retries_delay }}"
  27. until: result is not failed
  28. - block:
  29. - name: Ensure Coturn repository is present on self-build
  30. git:
  31. repo: "{{ matrix_coturn_container_image_self_build_repo }}"
  32. dest: "{{ matrix_coturn_docker_src_files_path }}"
  33. version: "{{ matrix_coturn_container_image_self_build_repo_version }}"
  34. force: "yes"
  35. become: true
  36. become_user: "{{ matrix_user_username }}"
  37. register: matrix_coturn_git_pull_results
  38. - name: Ensure Coturn Docker image is built
  39. docker_image:
  40. name: "{{ matrix_coturn_docker_image }}"
  41. source: build
  42. force_source: "{{ matrix_coturn_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  43. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_git_pull_results.changed }}"
  44. build:
  45. dockerfile: "{{ matrix_coturn_container_image_self_build_repo_dockerfile_path }}"
  46. path: "{{ matrix_coturn_docker_src_files_path }}"
  47. pull: true
  48. when: "matrix_coturn_container_image_self_build|bool"
  49. - name: Ensure Coturn configuration path exists
  50. file:
  51. path: "{{ matrix_coturn_base_path }}"
  52. state: directory
  53. mode: 0750
  54. owner: "{{ matrix_user_username }}"
  55. group: "{{ matrix_user_groupname }}"
  56. - name: Ensure turnserver.conf installed
  57. template:
  58. src: "{{ role_path }}/templates/turnserver.conf.j2"
  59. dest: "{{ matrix_coturn_config_path }}"
  60. mode: 0644
  61. owner: "{{ matrix_user_username }}"
  62. group: "{{ matrix_user_groupname }}"
  63. - name: Ensure Coturn network is created in Docker
  64. docker_network:
  65. name: "{{ matrix_coturn_docker_network }}"
  66. driver: bridge
  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_change_results
  73. # This may be unnecessary when more long-lived certificates are used.
  74. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  75. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  76. - name: Ensure reloading systemd units installed, if necessary
  77. template:
  78. src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
  79. dest: "{{ matrix_systemd_path }}/{{ item }}"
  80. mode: 0644
  81. register: "matrix_coturn_systemd_service_change_results"
  82. when: "matrix_coturn_tls_enabled|bool"
  83. with_items:
  84. - matrix-coturn-reload.service
  85. - matrix-coturn-reload.timer
  86. # A similar task exists in `setup_uninstall.yml`
  87. - name: Ensure reloading systemd units uninstalled, if unnecessary
  88. file:
  89. path: "{{ item }}"
  90. state: absent
  91. register: "matrix_coturn_systemd_service_change_results"
  92. when: "not matrix_coturn_tls_enabled|bool"
  93. with_items:
  94. - matrix-coturn-reload.service
  95. - matrix-coturn-reload.timer
  96. - name: Ensure systemd reloaded if systemd units changed
  97. service:
  98. daemon_reload: true
  99. when: "matrix_coturn_systemd_service_change_results.changed"