Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

132 Zeilen
6.2 KiB

  1. ---
  2. - when: matrix_coturn_turn_external_ip_address_auto_detection_enabled | bool
  3. block:
  4. - name: Fail if enabled, but EchoIP service URL unset
  5. when: matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_url == ''
  6. ansible.builtin.fail:
  7. msg: "To use the external IP address auto-detection feature, you need to set matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_url"
  8. # Note:
  9. # `ansible.builtin.uri` does not provide a way to configure whether IPv4 or IPv6 is used.
  10. # Luckily, the default instance we use does not define AAAA records for now, so it's always IPv4.
  11. - name: Fetch IP address information from EchoIP service
  12. ansible.builtin.uri:
  13. url: "{{ matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_url }}"
  14. headers:
  15. Content-Type: application/json
  16. follow_redirects: none
  17. validate_certs: "{{ matrix_coturn_turn_external_ip_address_auto_detection_echoip_validate_certs }}"
  18. register: result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response
  19. ignore_errors: true
  20. check_mode: false
  21. retries: "{{ matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_retries_count }}"
  22. delay: "{{ matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_retries_delay }}"
  23. until: not result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response.failed
  24. - name: Fail if EchoIP service failed
  25. when: "(result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response.failed or 'json' not in result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response)"
  26. ansible.builtin.fail:
  27. msg: "Failed contacting EchoIP service API at `{{ matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_url }}` (controlled by `matrix_coturn_turn_external_ip_address_auto_detection_echoip_service_url`). Full error: {{ result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response }}"
  28. - ansible.builtin.set_fact:
  29. matrix_coturn_turn_external_ip_address: "{{ result_matrix_coturn_turn_external_ip_address_auto_detection_echoip_response.json.ip }}"
  30. - name: Ensure Matrix Coturn path exists
  31. ansible.builtin.file:
  32. path: "{{ item.path }}"
  33. state: directory
  34. mode: 0750
  35. owner: "{{ matrix_user_username }}"
  36. group: "{{ matrix_user_groupname }}"
  37. with_items:
  38. - {path: "{{ matrix_coturn_docker_src_files_path }}", when: "{{ matrix_coturn_container_image_self_build }}"}
  39. when: "item.when | bool"
  40. - name: Ensure Coturn image is pulled
  41. community.docker.docker_image:
  42. name: "{{ matrix_coturn_docker_image }}"
  43. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  44. force_source: "{{ matrix_coturn_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  45. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_docker_image_force_pull }}"
  46. when: "not matrix_coturn_container_image_self_build | bool"
  47. register: result
  48. retries: "{{ devture_playbook_help_container_retries_count }}"
  49. delay: "{{ devture_playbook_help_container_retries_delay }}"
  50. until: result is not failed
  51. - when: "matrix_coturn_container_image_self_build | bool"
  52. block:
  53. - name: Ensure Coturn repository is present on self-build
  54. ansible.builtin.git:
  55. repo: "{{ matrix_coturn_container_image_self_build_repo }}"
  56. dest: "{{ matrix_coturn_docker_src_files_path }}"
  57. version: "{{ matrix_coturn_container_image_self_build_repo_version }}"
  58. force: "yes"
  59. become: true
  60. become_user: "{{ matrix_user_username }}"
  61. register: matrix_coturn_git_pull_results
  62. - name: Ensure Coturn Docker image is built
  63. community.docker.docker_image:
  64. name: "{{ matrix_coturn_docker_image }}"
  65. source: build
  66. force_source: "{{ matrix_coturn_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  67. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_coturn_git_pull_results.changed }}"
  68. build:
  69. dockerfile: "{{ matrix_coturn_container_image_self_build_repo_dockerfile_path }}"
  70. path: "{{ matrix_coturn_docker_src_files_path }}"
  71. pull: true
  72. - name: Ensure Coturn configuration path exists
  73. ansible.builtin.file:
  74. path: "{{ matrix_coturn_base_path }}"
  75. state: directory
  76. mode: 0750
  77. owner: "{{ matrix_user_username }}"
  78. group: "{{ matrix_user_groupname }}"
  79. - name: Ensure turnserver.conf installed
  80. ansible.builtin.template:
  81. src: "{{ role_path }}/templates/turnserver.conf.j2"
  82. dest: "{{ matrix_coturn_config_path }}"
  83. mode: 0644
  84. owner: "{{ matrix_user_username }}"
  85. group: "{{ matrix_user_groupname }}"
  86. - name: Ensure Coturn network is created in Docker
  87. when: matrix_coturn_container_network not in ['', 'host']
  88. community.docker.docker_network:
  89. name: "{{ matrix_coturn_container_network }}"
  90. driver: bridge
  91. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  92. - name: Ensure matrix-coturn.service installed
  93. ansible.builtin.template:
  94. src: "{{ role_path }}/templates/systemd/matrix-coturn.service.j2"
  95. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-coturn.service"
  96. mode: 0644
  97. # This may be unnecessary when more long-lived certificates are used.
  98. # We optimize for the common use-case though (short-lived Let's Encrypt certificates).
  99. # Reloading doesn't hurt anyway, so there's no need to make this more flexible.
  100. - name: Ensure reloading systemd units installed, if necessary
  101. ansible.builtin.template:
  102. src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
  103. dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ item }}"
  104. mode: 0644
  105. when: "matrix_coturn_tls_enabled | bool"
  106. with_items:
  107. - matrix-coturn-reload.service
  108. - matrix-coturn-reload.timer
  109. # A similar task exists in `setup_uninstall.yml`
  110. - name: Ensure reloading systemd units uninstalled, if unnecessary
  111. ansible.builtin.file:
  112. path: "{{ item }}"
  113. state: absent
  114. when: "not matrix_coturn_tls_enabled | bool"
  115. with_items:
  116. - matrix-coturn-reload.service
  117. - matrix-coturn-reload.timer