Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

112 řádky
5.8 KiB

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