Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

142 wiersze
7.2 KiB

  1. ---
  2. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  3. # We don't want to fail in such cases.
  4. - name: Fail if matrix-synapse role already executed
  5. fail:
  6. msg: >-
  7. The matrix-bridge-hookshot role needs to execute before the matrix-synapse role.
  8. when: "matrix_hookshot_enabled and matrix_synapse_role_executed|default(False)"
  9. - set_fact:
  10. matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-hookshot.service'] }}"
  11. when: matrix_hookshot_enabled|bool
  12. # If the matrix-synapse role is not used, these variables may not exist.
  13. - set_fact:
  14. matrix_synapse_container_extra_arguments: >
  15. {{
  16. matrix_synapse_container_extra_arguments|default([])
  17. +
  18. ["--mount type=bind,src={{ matrix_hookshot_base_path }}/registration.yml,dst=/hookshot-registration.yml,ro"]
  19. }}
  20. matrix_synapse_app_service_config_files: >
  21. {{
  22. matrix_synapse_app_service_config_files|default([])
  23. +
  24. ["/hookshot-registration.yml"]
  25. }}
  26. when: matrix_hookshot_enabled|bool
  27. - block:
  28. - name: Fail if matrix-nginx-proxy role already executed
  29. fail:
  30. msg: >-
  31. Trying to append hookshot's reverse-proxying configuration to matrix-nginx-proxy,
  32. but it's pointless since the matrix-nginx-proxy role had already executed.
  33. To fix this, please change the order of roles in your playbook,
  34. so that the matrix-nginx-proxy role would run after the matrix-bridge-hookshot role.
  35. when: matrix_nginx_proxy_role_executed|default(False)|bool
  36. - name: Generate Matrix hookshot proxying configuration for matrix-nginx-proxy
  37. set_fact:
  38. matrix_hookshot_matrix_nginx_proxy_configuration: |
  39. location ~ ^{{ matrix_hookshot_appservice_endpoint }}/(.*)$ {
  40. {% if matrix_nginx_proxy_enabled|default(False) %}
  41. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  42. resolver 127.0.0.11 valid=5s;
  43. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_appservice_port }}";
  44. proxy_pass http://$backend/$1;
  45. {% else %}
  46. {# Generic configuration for use outside of our container setup #}
  47. proxy_pass http://127.0.0.1:{{ matrix_hookshot_appservice_port }}/$1;
  48. {% endif %}
  49. proxy_set_header Host $host;
  50. }
  51. {% if matrix_hookshot_provisioning_enabled %}
  52. location ~ ^{{ matrix_hookshot_provisioning_endpoint }}/(.*)$ {
  53. {% if matrix_nginx_proxy_enabled|default(False) %}
  54. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  55. resolver 127.0.0.11 valid=5s;
  56. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_provisioning_port }}";
  57. proxy_pass http://$backend{{ matrix_hookshot_provisioning_internal }}/$1$is_args$args;
  58. {% else %}
  59. {# Generic configuration for use outside of our container setup #}
  60. proxy_pass http://127.0.0.1:{{ matrix_hookshot_provisioning_port }}{{ matrix_hookshot_provisioning_internal }}/$1$is_args$args;
  61. {% endif %}
  62. proxy_set_header Host $host;
  63. }
  64. {% endif %}
  65. {% if matrix_hookshot_widgets_enabled %}
  66. location ~ ^{{ matrix_hookshot_widgets_endpoint }}/(.*)$ {
  67. {% if matrix_nginx_proxy_enabled|default(False) %}
  68. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  69. resolver 127.0.0.11 valid=5s;
  70. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_widgets_port }}";
  71. proxy_pass http://$backend{{ matrix_hookshot_widgets_internal }}/$1$is_args$args;
  72. {% else %}
  73. {# Generic configuration for use outside of our container setup #}
  74. proxy_pass http://127.0.0.1:{{ matrix_hookshot_widgets_port }}{{ matrix_hookshot_widgets_internal }}/$1$is_args$args;
  75. {% endif %}
  76. proxy_set_header Host $host;
  77. }
  78. {% endif %}
  79. location ~ ^{{ matrix_hookshot_webhook_endpoint }}/(.*)$ {
  80. {% if matrix_nginx_proxy_enabled|default(False) %}
  81. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  82. resolver 127.0.0.11 valid=5s;
  83. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_webhook_port }}";
  84. proxy_pass http://$backend/$1$is_args$args;
  85. {% else %}
  86. {# Generic configuration for use outside of our container setup #}
  87. proxy_pass http://127.0.0.1:{{ matrix_hookshot_webhook_port }}/$1$is_args$args;
  88. {% endif %}
  89. proxy_set_header Host $host;
  90. }
  91. - name: Register hookshot proxying configuration with matrix-nginx-proxy
  92. set_fact:
  93. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  94. {{
  95. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  96. +
  97. [matrix_hookshot_matrix_nginx_proxy_configuration]
  98. }}
  99. - name: Generate hookshot metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot)
  100. set_fact:
  101. matrix_hookshot_matrix_nginx_proxy_metrics_configuration_matrix_domain: |
  102. location /metrics/hookshot {
  103. {% if matrix_nginx_proxy_enabled|default(False) %}
  104. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  105. resolver 127.0.0.11 valid=5s;
  106. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_metrics_port }}";
  107. proxy_pass http://$backend/metrics;
  108. {% else %}
  109. {# Generic configuration for use outside of our container setup #}
  110. proxy_pass http://127.0.0.1:{{ matrix_hookshot_metrics_port }}/metrics;
  111. {% endif %}
  112. }
  113. when: matrix_hookshot_metrics_enabled|bool and matrix_hookshot_metrics_proxying_enabled|bool
  114. - name: Register hookshot metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot)
  115. set_fact:
  116. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: |
  117. {{
  118. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([])
  119. +
  120. [matrix_hookshot_matrix_nginx_proxy_metrics_configuration_matrix_domain]
  121. }}
  122. when: matrix_hookshot_metrics_enabled|bool and matrix_hookshot_metrics_proxying_enabled|bool
  123. when: matrix_hookshot_enabled|bool
  124. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  125. debug:
  126. msg: >-
  127. NOTE: You've enabled the hookshot bridge but are not using the matrix-nginx-proxy
  128. reverse proxy.
  129. Please make sure that you're proxying the `{{ matrix_hookshot_public_endpoint }}`
  130. URL endpoint to the matrix-hookshot container.
  131. You can expose the container's ports using the `matrix_hookshot_container_http_host_bind_ports` variable.
  132. when: "matrix_hookshot_enabled|bool and not matrix_nginx_proxy_enabled|default(False)|bool"