Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

82 lines
3.8 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-appservice-webhooks role needs to execute before the matrix-synapse role.
  7. when: "matrix_synapse_role_executed|default(False)"
  8. - set_fact:
  9. matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-webhooks.service'] }}"
  10. when: matrix_appservice_webhooks_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_appservice_webhooks_config_path }}/webhooks-registration.yaml,dst=/matrix-appservice-webhooks-registration.yaml,ro"]
  17. matrix_synapse_app_service_config_files: >
  18. {{ matrix_synapse_app_service_config_files|default([]) }}
  19. +
  20. {{ ["/matrix-appservice-webhooks-registration.yaml"] }}
  21. when: matrix_appservice_webhooks_enabled|bool
  22. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  23. # We don't want to fail in such cases.
  24. - name: Fail if matrix-synapse role already executed
  25. fail:
  26. msg: >-
  27. The matrix-bridge-appservice-webhooks role needs to execute before the matrix-synapse role.
  28. when: "matrix_synapse_role_executed|default(False)"
  29. - block:
  30. - name: Fail if matrix-nginx-proxy role already executed
  31. fail:
  32. msg: >-
  33. Trying to append webhooks Appservice's reverse-proxying configuration to matrix-nginx-proxy,
  34. but it's pointless since the matrix-nginx-proxy role had already executed.
  35. To fix this, please change the order of roles in your plabook,
  36. so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-webhooks role.
  37. when: matrix_nginx_proxy_role_executed|default(False)|bool
  38. - name: Generate Matrix Appservice webhooks proxying configuration for matrix-nginx-proxy
  39. set_fact:
  40. matrix_appservice_webhooks_matrix_nginx_proxy_configuration: |
  41. {% if matrix_nginx_proxy_enabled|default(False) %}
  42. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  43. location ~ ^{{ matrix_appservice_webhooks_public_endpoint }}/(.*)$ {
  44. resolver 127.0.0.11 valid=5s;
  45. set $backend "matrix-appservice-webhooks:{{ matrix_appservice_webhooks_matrix_port }}";
  46. proxy_pass http://$backend/$1;
  47. }
  48. {% else %}
  49. {# Generic configuration for use outside of our container setup #}
  50. location {{ matrix_appservice_webhooks_public_endpoint }}/ {
  51. proxy_pass http://127.0.0.1:{{ matrix_appservice_webhooks_matrix_port }}/;
  52. }
  53. {% endif %}
  54. - name: Register webhooks Appservice proxying configuration with matrix-nginx-proxy
  55. set_fact:
  56. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  57. {{
  58. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  59. +
  60. [matrix_appservice_webhooks_matrix_nginx_proxy_configuration]
  61. }}
  62. tags:
  63. - always
  64. when: matrix_appservice_webhooks_enabled|bool
  65. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  66. debug:
  67. msg: >-
  68. NOTE: You've enabled the Matrix webhooks bridge but are not using the matrix-nginx-proxy
  69. reverse proxy.
  70. Please make sure that you're proxying the `{{ matrix_appservice_webhooks_public_endpoint }}`
  71. URL endpoint to the matrix-appservice-webhooks container.
  72. You can expose the container's port using the `matrix_appservice_webhooks_container_http_host_bind_port` variable.
  73. when: "matrix_appservice_webhooks_enabled|bool and matrix_nginx_proxy_enabled is not defined"