Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

92 righe
4.5 KiB

  1. ---
  2. # See https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1070
  3. # and https://github.com/spantaleev/matrix-docker-ansible-deploy/commit/1ab507349c752042d26def3e95884f6df8886b74#commitcomment-51108407
  4. - name: Fail if trying to self-build on Ansible < 2.8
  5. ansible.builtin.fail:
  6. msg: "To self-build the matrix-appservice-slack image, you should use Ansible 2.8 or higher. See docs/ansible.md"
  7. when: "ansible_version.major == 2 and ansible_version.minor < 8 and matrix_appservice_slack_container_image_self_build and matrix_appservice_slack_enabled"
  8. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  9. # We don't want to fail in such cases.
  10. - name: Fail if matrix-synapse role already executed
  11. ansible.builtin.fail:
  12. msg: >-
  13. The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role.
  14. when: "matrix_synapse_role_executed | default(False)"
  15. - ansible.builtin.set_fact:
  16. matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-appservice-slack.service'] }}"
  17. when: matrix_appservice_slack_enabled | bool
  18. # If the matrix-synapse role is not used, these variables may not exist.
  19. - ansible.builtin.set_fact:
  20. matrix_homeserver_container_runtime_injected_arguments: >
  21. {{
  22. matrix_homeserver_container_runtime_injected_arguments | default([])
  23. +
  24. ["--mount type=bind,src={{ matrix_appservice_slack_config_path }}/slack-registration.yaml,dst=/matrix-appservice-slack-registration.yaml,ro"]
  25. }}
  26. matrix_homeserver_app_service_runtime_injected_config_files: >
  27. {{
  28. matrix_homeserver_app_service_runtime_injected_config_files | default([])
  29. +
  30. ["/matrix-appservice-slack-registration.yaml"]
  31. }}
  32. when: matrix_appservice_slack_enabled | bool
  33. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  34. # We don't want to fail in such cases.
  35. - name: Fail if matrix-synapse role already executed
  36. ansible.builtin.fail:
  37. msg: >-
  38. The matrix-bridge-appservice-slack role needs to execute before the matrix-synapse role.
  39. when: "matrix_synapse_role_executed | default(False)"
  40. - block:
  41. - name: Fail if matrix-nginx-proxy role already executed
  42. ansible.builtin.fail:
  43. msg: >-
  44. Trying to append Slack Appservice's reverse-proxying configuration to matrix-nginx-proxy,
  45. but it's pointless since the matrix-nginx-proxy role had already executed.
  46. To fix this, please change the order of roles in your playbook,
  47. so that the matrix-nginx-proxy role would run after the matrix-bridge-appservice-slack role.
  48. when: matrix_nginx_proxy_role_executed | default(False) | bool
  49. - name: Generate Matrix Appservice Slack proxying configuration for matrix-nginx-proxy
  50. ansible.builtin.set_fact:
  51. matrix_appservice_slack_matrix_nginx_proxy_configuration: |
  52. location {{ matrix_appservice_slack_public_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_appservice_slack_appservice_url }}:{{ matrix_appservice_slack_slack_port }}";
  57. proxy_pass $backend;
  58. {% else %}
  59. {# Generic configuration for use outside of our container setup #}
  60. proxy_pass http://127.0.0.1:{{ matrix_appservice_slack_slack_port }};
  61. {% endif %}
  62. }
  63. - name: Register Slack Appservice proxying configuration with matrix-nginx-proxy
  64. ansible.builtin.set_fact:
  65. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  66. {{
  67. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([])
  68. +
  69. [matrix_appservice_slack_matrix_nginx_proxy_configuration]
  70. }}
  71. tags:
  72. - always
  73. when: matrix_appservice_slack_enabled | bool
  74. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  75. ansible.builtin.debug:
  76. msg: >-
  77. NOTE: You've enabled the Matrix Slack bridge but are not using the matrix-nginx-proxy
  78. reverse proxy.
  79. Please make sure that you're proxying the `{{ something }}`
  80. URL endpoint to the matrix-appservice-slack container.
  81. You can expose the container's port using the `matrix_appservice_slack_container_http_host_bind_port` variable.
  82. when: "matrix_appservice_slack_enabled | bool and not matrix_nginx_proxy_enabled | default(False) | bool"