Matrix Docker Ansible eploy
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

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