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

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