Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

130 satır
6.1 KiB

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