Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

131 строка
6.3 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/v1/$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 }}/v1/$1$is_args$args;
  57. {% endif %}
  58. proxy_set_header Host $host;
  59. }
  60. {% endif %}
  61. location ~ ^{{ matrix_hookshot_webhook_endpoint }}/(.*)$ {
  62. {% if matrix_nginx_proxy_enabled|default(False) %}
  63. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  64. resolver 127.0.0.11 valid=5s;
  65. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_webhook_port }}";
  66. proxy_pass http://$backend/$1$is_args$args;
  67. {% else %}
  68. {# Generic configuration for use outside of our container setup #}
  69. proxy_pass http://127.0.0.1:{{ matrix_hookshot_webhook_port }}/$1$is_args$args;
  70. {% endif %}
  71. proxy_set_header Host $host;
  72. }
  73. - name: Register hookshot proxying configuration with matrix-nginx-proxy
  74. set_fact:
  75. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  76. {{
  77. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  78. +
  79. [matrix_hookshot_matrix_nginx_proxy_configuration]
  80. }}
  81. - name: Generate Matrix hookshot proxying configuration for matrix-nginx-proxy
  82. set_fact:
  83. matrix_hookshot_matrix_nginx_proxy_metrics_configuration: |
  84. {% if matrix_hookshot_metrics_enabled and matrix_hookshot_proxy_metrics %}
  85. location {{ matrix_hookshot_metrics_endpoint }} {
  86. {% if matrix_nginx_proxy_enabled|default(False) %}
  87. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  88. resolver 127.0.0.11 valid=5s;
  89. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_metrics_port }}";
  90. proxy_pass http://$backend/metrics;
  91. {% else %}
  92. {# Generic configuration for use outside of our container setup #}
  93. proxy_pass http://127.0.0.1:{{ matrix_hookshot_metrics_port }}/metrics;
  94. {% endif %}
  95. proxy_set_header Host $host;
  96. {% if matrix_hookshot_proxy_metrics_basic_auth_enabled %}
  97. auth_basic "protected";
  98. auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
  99. {% endif %}
  100. }
  101. {% endif %}
  102. - name: Register hookshot metrics proxying configuration with matrix-nginx-proxy
  103. set_fact:
  104. matrix_nginx_proxy_proxy_grafana_additional_server_configuration_blocks: |
  105. {{
  106. matrix_nginx_proxy_proxy_grafana_additional_server_configuration_blocks|default([])
  107. +
  108. [matrix_hookshot_matrix_nginx_proxy_metrics_configuration]
  109. }}
  110. tags:
  111. - always
  112. when: matrix_hookshot_enabled|bool
  113. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  114. debug:
  115. msg: >-
  116. NOTE: You've enabled the hookshot bridge but are not using the matrix-nginx-proxy
  117. reverse proxy.
  118. Please make sure that you're proxying the `{{ matrix_hookshot_public_endpoint }}`
  119. URL endpoint to the matrix-hookshot container.
  120. You can expose the container's ports using the `matrix_hookshot_container_http_host_bind_ports` variable.
  121. when: "matrix_hookshot_enabled|bool and not matrix_nginx_proxy_enabled|default(False)|bool"