Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

110 lines
4.1 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. register: matrix_coturn_git_pull_results
  36. - name: Ensure Coturn Docker image is built
  37. docker_image:
  38. name: "{{ matrix_coturn_docker_image }}"
  39. source: build
  40. force_source: "{{ matrix_coturn_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  41. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_git_pull_results.changed }}"
  42. build:
  43. dockerfile: "{{ matrix_coturn_container_image_self_build_repo_dockerfile_path }}"
  44. path: "{{ matrix_coturn_docker_src_files_path }}"
  45. pull: true
  46. when: "matrix_coturn_container_image_self_build|bool"
  47. - name: Ensure Coturn configuration path exists
  48. file:
  49. path: "{{ matrix_coturn_base_path }}"
  50. state: directory
  51. mode: 0750
  52. owner: "{{ matrix_user_username }}"
  53. group: "{{ matrix_user_groupname }}"
  54. - name: Ensure turnserver.conf installed
  55. template:
  56. src: "{{ role_path }}/templates/turnserver.conf.j2"
  57. dest: "{{ matrix_coturn_config_path }}"
  58. mode: 0644
  59. owner: "{{ matrix_user_username }}"
  60. group: "{{ matrix_user_groupname }}"
  61. - name: Ensure Coturn network is created in Docker
  62. docker_network:
  63. name: "{{ matrix_coturn_docker_network }}"
  64. driver: bridge
  65. - name: Ensure matrix-coturn.service installed
  66. template:
  67. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  68. dest: "{{ matrix_systemd_path }}/matrix-coturn.service"
  69. mode: 0644
  70. register: matrix_coturn_systemd_service_change_results
  71. # This may be unnecessary when more long-lived certificates are used.
  72. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  73. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  74. - name: Ensure reloading systemd units installed, if necessary
  75. template:
  76. src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
  77. dest: "{{ matrix_systemd_path }}/{{ item }}"
  78. mode: 0644
  79. register: "matrix_coturn_systemd_service_change_results"
  80. when: "matrix_coturn_tls_enabled|bool"
  81. with_items:
  82. - matrix-coturn-reload.service
  83. - matrix-coturn-reload.timer
  84. # A similar task exists in `setup_uninstall.yml`
  85. - name: Ensure reloading systemd units uninstalled, if unnecessary
  86. file:
  87. path: "{{ item }}"
  88. state: absent
  89. register: "matrix_coturn_systemd_service_change_results"
  90. when: "not matrix_coturn_tls_enabled|bool"
  91. with_items:
  92. - matrix-coturn-reload.service
  93. - matrix-coturn-reload.timer
  94. - name: Ensure systemd reloaded if systemd units changed
  95. service:
  96. daemon_reload: true
  97. when: "matrix_coturn_systemd_service_change_results.changed"