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.
 
 

114 wiersze
6.2 KiB

  1. ---
  2. - when: matrix_hookshot_enabled | bool
  3. block:
  4. - name: Fail if matrix-nginx-proxy role already executed
  5. ansible.builtin.fail:
  6. msg: >-
  7. Trying to append hookshot's reverse-proxying configuration to matrix-nginx-proxy,
  8. but it's pointless since the matrix-nginx-proxy role had already executed.
  9. To fix this, please change the order of roles in your playbook,
  10. so that the matrix-nginx-proxy role would run after the matrix-bridge-hookshot role.
  11. when: matrix_nginx_proxy_role_executed | default(False) | bool
  12. - name: Generate Matrix hookshot proxying configuration for matrix-nginx-proxy
  13. ansible.builtin.set_fact:
  14. matrix_hookshot_matrix_nginx_proxy_configuration: |
  15. location ~ ^{{ matrix_hookshot_appservice_endpoint }}/(.*)$ {
  16. {% if matrix_nginx_proxy_enabled | default(False) %}
  17. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  18. resolver 127.0.0.11 valid=5s;
  19. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_appservice_port }}";
  20. proxy_pass http://$backend/$1;
  21. {% else %}
  22. {# Generic configuration for use outside of our container setup #}
  23. proxy_pass http://127.0.0.1:{{ matrix_hookshot_appservice_port }}/$1;
  24. {% endif %}
  25. proxy_set_header Host $host;
  26. }
  27. {% if matrix_hookshot_provisioning_enabled %}
  28. location ~ ^{{ matrix_hookshot_provisioning_endpoint }}/(.*)$ {
  29. {% if matrix_nginx_proxy_enabled | default(False) %}
  30. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  31. resolver 127.0.0.11 valid=5s;
  32. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_provisioning_port }}";
  33. proxy_pass http://$backend{{ matrix_hookshot_provisioning_internal }}/$1$is_args$args;
  34. {% else %}
  35. {# Generic configuration for use outside of our container setup #}
  36. proxy_pass http://127.0.0.1:{{ matrix_hookshot_provisioning_port }}{{ matrix_hookshot_provisioning_internal }}/$1$is_args$args;
  37. {% endif %}
  38. proxy_set_header Host $host;
  39. }
  40. {% endif %}
  41. {% if matrix_hookshot_widgets_enabled %}
  42. location ~ ^{{ matrix_hookshot_widgets_endpoint }}/(.*)$ {
  43. {% if matrix_nginx_proxy_enabled | default(False) %}
  44. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  45. resolver 127.0.0.11 valid=5s;
  46. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_widgets_port }}";
  47. proxy_pass http://$backend{{ matrix_hookshot_widgets_internal }}/$1$is_args$args;
  48. {% else %}
  49. {# Generic configuration for use outside of our container setup #}
  50. proxy_pass http://127.0.0.1:{{ matrix_hookshot_widgets_port }}{{ matrix_hookshot_widgets_internal }}/$1$is_args$args;
  51. {% endif %}
  52. proxy_set_header Host $host;
  53. }
  54. {% endif %}
  55. location ~ ^{{ matrix_hookshot_webhook_endpoint }}/(.*)$ {
  56. {% if matrix_nginx_proxy_enabled | default(False) %}
  57. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  58. resolver 127.0.0.11 valid=5s;
  59. set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_webhook_port }}";
  60. proxy_pass http://$backend/$1$is_args$args;
  61. {% else %}
  62. {# Generic configuration for use outside of our container setup #}
  63. proxy_pass http://127.0.0.1:{{ matrix_hookshot_webhook_port }}/$1$is_args$args;
  64. {% endif %}
  65. proxy_set_header Host $host;
  66. }
  67. - name: Register hookshot proxying configuration with matrix-nginx-proxy
  68. ansible.builtin.set_fact:
  69. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  70. {{
  71. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
  72. +
  73. [matrix_hookshot_matrix_nginx_proxy_configuration]
  74. }}
  75. - name: Generate hookshot metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot)
  76. ansible.builtin.set_fact:
  77. matrix_hookshot_matrix_nginx_proxy_metrics_configuration_matrix_domain: |
  78. location /metrics/hookshot {
  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_metrics_port }}";
  83. proxy_pass http://$backend/metrics;
  84. {% else %}
  85. {# Generic configuration for use outside of our container setup #}
  86. proxy_pass http://127.0.0.1:{{ matrix_hookshot_metrics_port }}/metrics;
  87. {% endif %}
  88. }
  89. when: matrix_hookshot_metrics_enabled | bool and matrix_hookshot_metrics_proxying_enabled | bool
  90. - name: Register hookshot metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/hookshot)
  91. ansible.builtin.set_fact:
  92. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: |
  93. {{
  94. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks | default([])
  95. +
  96. [matrix_hookshot_matrix_nginx_proxy_metrics_configuration_matrix_domain]
  97. }}
  98. when: matrix_hookshot_metrics_enabled | bool and matrix_hookshot_metrics_proxying_enabled | bool
  99. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  100. ansible.builtin.debug:
  101. msg: >-
  102. NOTE: You've enabled the hookshot bridge but are not using the matrix-nginx-proxy
  103. reverse proxy.
  104. Please make sure that you're proxying the `{{ matrix_hookshot_public_endpoint }}`
  105. URL endpoint to the matrix-hookshot container.
  106. You can expose the container's ports using the `matrix_hookshot_container_http_host_bind_ports` variable.
  107. when: "matrix_hookshot_enabled | bool and not matrix_nginx_proxy_enabled | default(False) | bool"