Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

119 Zeilen
4.8 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. fail:
  6. msg: >-
  7. The matrix-bridge-mautrix-wsproxy role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - set_fact:
  10. matrix_mautrix_wsproxy_requires_restart: false
  11. - name: Ensure Mautrix wsproxy image is pulled
  12. docker_image:
  13. name: "{{ matrix_mautrix_wsproxy_docker_image }}"
  14. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  15. force_source: "{{ matrix_mautrix_wsproxy_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  16. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_wsproxy_docker_image_force_pull }}"
  17. - name: Ensure Mautrix wsproxy paths exists
  18. file:
  19. path: "{{ item }}"
  20. state: directory
  21. mode: 0750
  22. owner: "{{ matrix_user_username }}"
  23. group: "{{ matrix_user_groupname }}"
  24. with_items:
  25. - "{{ matrix_mautrix_wsproxy_base_path }}"
  26. - "{{ matrix_mautrix_wsproxy_config_path }}"
  27. - "{{ matrix_mautrix_wsproxy_data_path }}"
  28. - name: Check if an old matrix state file exists
  29. stat:
  30. path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json"
  31. register: matrix_mautrix_wsproxy_stat_mx_state
  32. - name: Ensure mautrix-wsproxy config.yaml installed
  33. copy:
  34. content: "{{ matrix_mautrix_wsproxy_configuration|to_nice_yaml }}"
  35. dest: "{{ matrix_mautrix_wsproxy_config_path }}/config.yaml"
  36. mode: 0644
  37. owner: "{{ matrix_user_username }}"
  38. group: "{{ matrix_user_groupname }}"
  39. - name: Ensure mautrix-wsproxy registration.yaml installed
  40. copy:
  41. content: "{{ matrix_mautrix_wsproxy_registration|to_nice_yaml }}"
  42. dest: "{{ matrix_mautrix_wsproxy_config_path }}/registration.yaml"
  43. mode: 0644
  44. owner: "{{ matrix_user_username }}"
  45. group: "{{ matrix_user_groupname }}"
  46. - name: Fail if matrix-nginx-proxy role already executed
  47. fail:
  48. msg: >-
  49. Trying to append mautrix-wsproxy reverse-proxying configuration to matrix-nginx-proxy,
  50. but it's pointless since the matrix-nginx-proxy role had already executed.
  51. To fix this, please change the order of roles in your plabook,
  52. so that the matrix-nginx-proxy role would run after the matrix-wspoxy role.
  53. when: matrix_nginx_proxy_role_executed|default(False)|bool and matrix_mautrix_wsproxy_enabled|bool
  54. - name: Generate Wsproxy proxying configuration for matrix-nginx-proxy
  55. set_fact:
  56. matrix_mautrix_wsproxy_matrix_nginx_proxy_configuration: |
  57. location ~ ^/(_matrix/client/unstable/fi.mau.syncproxy/*) {
  58. {% if matrix_nginx_proxy_enabled|default(False) %}
  59. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  60. resolver 127.0.0.11 valid=5s;
  61. set $backend "matrix-mautrix-wsproxy:{{ matrix_mautrix_wsproxy_port }}/$1";
  62. proxy_pass http://$backend;
  63. proxy_set_header Upgrade $http_upgrade;
  64. proxy_set_header Connection "upgrade";
  65. {% else %}
  66. {# Generic configuration for use outside of our container setup #}
  67. proxy_pass http://127.0.0.1:{{ matrix_mautrix_wsproxy_port }}/$1;
  68. proxy_set_header Upgrade $http_upgrade;
  69. proxy_set_header Connection "upgrade";
  70. {% endif %}
  71. }
  72. when: matrix_mautrix_wsproxy_enabled|bool
  73. - name: Register Wsproxy's proxying configuration with matrix-nginx-proxy
  74. set_fact:
  75. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  76. {{
  77. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  78. +
  79. [matrix_bot_maubot_matrix_nginx_proxy_configuration]
  80. }}
  81. when: matrix_mautrix_wsproxy_enabled|bool
  82. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  83. debug:
  84. msg: >-
  85. NOTE: You've enabled mautrix-wsproxy but are not using the matrix-nginx-proxy
  86. reverse proxy.
  87. Please make sure that you're proxying the `/_matrix/client/unstable/fi.mau.syncproxy`
  88. URL endpoint to the mautrix-wsproxy container.
  89. when: "matrix_mautrix_wsproxy_enabled|bool and matrix_nginx_proxy_enabled is not defined"
  90. - name: Ensure matrix-mautrix-wsproxy.service installed
  91. template:
  92. src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy.service.j2"
  93. dest: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service"
  94. mode: 0644
  95. register: matrix_mautrix_wsproxy_systemd_service_result
  96. - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation
  97. service:
  98. daemon_reload: yes
  99. when: "matrix_mautrix_wsproxy_systemd_service_result.changed"
  100. - name: Ensure matrix-mautrix-wsproxy.service restarted, if necessary
  101. service:
  102. name: "matrix-mautrix-wsproxy.service"
  103. state: restarted
  104. when: "matrix_mautrix_wsproxy_requires_restart|bool"