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.
 
 

78 lines
4.4 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - ansible.builtin.set_fact:
  6. well_known_url_matrix: "{{ matrix_static_files_scheme }}://{{ matrix_static_files_self_check_hostname_matrix }}{{ well_known_file_check.path }}"
  7. well_known_url_identity: "{{ matrix_static_files_scheme }}://{{ matrix_static_files_self_check_hostname_identity }}{{ well_known_file_check.path }}"
  8. # These well-known files may be served without a `Content-Type: application/json` header,
  9. # so we can't rely on the uri module's automatic parsing of JSON.
  10. - name: Check .well-known on the Matrix hostname
  11. ansible.builtin.uri:
  12. url: "{{ well_known_url_matrix }}"
  13. follow_redirects: none
  14. return_content: true
  15. validate_certs: "{{ well_known_file_check.validate_certs }}"
  16. headers:
  17. Origin: example.com
  18. check_mode: false
  19. register: result_well_known_matrix
  20. ignore_errors: true
  21. - name: Fail if .well-known not working on the Matrix hostname
  22. ansible.builtin.fail:
  23. msg: "Failed checking that the well-known file for {{ well_known_file_check.purpose }} is configured at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`). Is port 443 open in your firewall? Full error: {{ result_well_known_matrix }}"
  24. when: "result_well_known_matrix.failed"
  25. - name: Parse JSON for well-known payload at the Matrix hostname
  26. ansible.builtin.set_fact:
  27. well_known_matrix_payload: "{{ result_well_known_matrix.content | from_json }}"
  28. - name: Fail if .well-known not CORS-aware on the Matrix hostname
  29. ansible.builtin.fail:
  30. msg: "The well-known file for {{ well_known_file_check.purpose }} on `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`) is not CORS-aware. The file needs to be served with an Access-Control-Allow-Origin header set."
  31. when: "well_known_file_check.cors and 'access_control_allow_origin' not in result_well_known_matrix"
  32. - name: Report working .well-known on the Matrix hostname
  33. ansible.builtin.debug:
  34. msg: "well-known for {{ well_known_file_check.purpose }} is configured correctly for `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ well_known_url_matrix }}`)"
  35. - name: Check .well-known on the identity hostname
  36. ansible.builtin.uri:
  37. url: "{{ well_known_url_identity }}"
  38. follow_redirects: "{{ well_known_file_check.follow_redirects }}"
  39. return_content: true
  40. validate_certs: "{{ well_known_file_check.validate_certs }}"
  41. headers:
  42. Origin: example.com
  43. check_mode: false
  44. register: result_well_known_identity
  45. ignore_errors: true
  46. - name: Fail if .well-known not working on the identity hostname
  47. ansible.builtin.fail:
  48. msg: "Failed checking that the well-known file for {{ well_known_file_check.purpose }} is configured at `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`). Is port 443 open in your firewall? Full error: {{ result_well_known_identity }}"
  49. when: "result_well_known_identity.failed"
  50. - name: Parse JSON for well-known payload at the identity hostname
  51. ansible.builtin.set_fact:
  52. well_known_identity_payload: "{{ result_well_known_identity.content | from_json }}"
  53. - name: Fail if .well-known not CORS-aware on the identity hostname
  54. ansible.builtin.fail:
  55. msg: "The well-known file for {{ well_known_file_check.purpose }} on `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`) is not CORS-aware. The file needs to be served with an Access-Control-Allow-Origin header set. See docs/configuring-well-known.md"
  56. when: "well_known_file_check.cors and 'access_control_allow_origin' not in result_well_known_identity"
  57. # For people who manually copy the well-known file, try to detect if it's outdated
  58. - name: Fail if well-known is different on Matrix hostname and identity hostname
  59. ansible.builtin.fail:
  60. msg: "The well-known files for {{ well_known_file_check.purpose }} at `{{ matrix_server_fqn_matrix }}` and `{{ matrix_domain }}` are different. Perhaps you copied the file ({{ well_known_file_check.path }}) manually before and now it's outdated?"
  61. when: "well_known_matrix_payload != well_known_identity_payload"
  62. - name: Report working .well-known on the identity hostname
  63. ansible.builtin.debug:
  64. msg: "well-known for {{ well_known_file_check.purpose }} ({{ well_known_file_check.path }}) is configured correctly for `{{ matrix_domain }}` (checked endpoint: `{{ well_known_url_identity }}`)"