Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

117 lignes
5.5 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.yaml,dst=/hookshot-registration.yaml,ro"]
  17. matrix_synapse_app_service_config_files: >
  18. {{ matrix_synapse_app_service_config_files|default([]) }}
  19. +
  20. {{ ["/hookshot-registration.yaml"] }}
  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. {% if matrix_hookshot_metrics_enabled %}
  35. location {{ matrix_hookshot_metrics_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_metrics_port }}";
  40. proxy_pass http://$backend/metrics;
  41. {% else %}
  42. {# Generic configuration for use outside of our container setup #}
  43. proxy_pass http://127.0.0.1:{{ matrix_hookshot_metrics_port }}/metrics;
  44. {% endif %}
  45. proxy_set_header Host $host;
  46. {% if matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled %}
  47. auth_basic "protected";
  48. auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
  49. {% endif %}
  50. }
  51. {% endif %}
  52. location ~ ^{{ matrix_hookshot_appservice_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_appservice_port }}";
  57. proxy_pass http://$backend/$1;
  58. {% else %}
  59. {# Generic configuration for use outside of our container setup #}
  60. proxy_pass http://127.0.0.1:{{ matrix_hookshot_appservice_port }}/$1;
  61. {% endif %}
  62. proxy_set_header Host $host;
  63. }
  64. {% if matrix_hookshot_provisioning_enabled %}
  65. location ~ ^{{ matrix_hookshot_provisioning_endpoint }}/(.*)$ {
  66. {% if matrix_nginx_proxy_enabled|default(False) %}
  67. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  68. resolver 127.0.0.11 valid=5s;
  69. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_provisioning_port }}";
  70. proxy_pass http://$backend/$1;
  71. {% else %}
  72. {# Generic configuration for use outside of our container setup #}
  73. proxy_pass http://127.0.0.1:{{ matrix_hookshot_provisioning_port }}/$1;
  74. {% endif %}
  75. proxy_set_header Host $host;
  76. }
  77. {% endif %}
  78. location ~ ^{{ matrix_hookshot_webhook_endpoint }}/(.*)$ {
  79. {% if matrix_nginx_proxy_enabled|default(False) %}
  80. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  81. resolver 127.0.0.11 valid=5s;
  82. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_webhook_port }}";
  83. proxy_pass http://$backend/$1;
  84. {% else %}
  85. {# Generic configuration for use outside of our container setup #}
  86. proxy_pass http://127.0.0.1:{{ matrix_hookshot_webhook_port }}/$1;
  87. {% endif %}
  88. proxy_set_header Host $host;
  89. }
  90. - name: Register hookshot proxying configuration with matrix-nginx-proxy
  91. set_fact:
  92. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  93. {{
  94. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  95. +
  96. [matrix_hookshot_matrix_nginx_proxy_configuration]
  97. }}
  98. tags:
  99. - always
  100. when: matrix_hookshot_enabled|bool
  101. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  102. debug:
  103. msg: >-
  104. NOTE: You've enabled the hookshot bridge but are not using the matrix-nginx-proxy
  105. reverse proxy.
  106. Please make sure that you're proxying the `{{ matrix_hookshot_public_endpoint }}`
  107. URL endpoint to the matrix-hookshot container.
  108. You can expose the container's ports using the `matrix_hookshot_container_http_host_bind_ports` variable.
  109. when: "matrix_hookshot_enabled|bool and matrix_nginx_proxy_enabled is not defined"