Просмотр исходного кода

Add self-check for the matrix-corporal HTTP API (if enabled)

pull/3093/head
Slavi Pantaleev 2 лет назад
Родитель
Сommit
a9a1448f62
2 измененных файлов: 25 добавлений и 0 удалений
  1. +1
    -0
      roles/custom/matrix-corporal/defaults/main.yml
  2. +24
    -0
      roles/custom/matrix-corporal/tasks/self_check.yml

+ 1
- 0
roles/custom/matrix-corporal/defaults/main.yml Просмотреть файл

@@ -165,3 +165,4 @@ matrix_corporal_configuration_extension: "{{ matrix_corporal_configuration_exten
matrix_corporal_configuration: "{{ matrix_corporal_configuration_default | combine(matrix_corporal_configuration_extension, recursive=True) }}"

matrix_corporal_self_check_matrix_client_api_url_endpoint_public: "https://{{ matrix_corporal_matrix_homeserver_api_domain_name }}/_matrix/client/corporal"
matrix_corporal_self_check_corporal_api_url_endpoint_public: "https://{{ matrix_corporal_matrix_homeserver_api_domain_name }}/_matrix/corporal/policy"

+ 24
- 0
roles/custom/matrix-corporal/tasks/self_check.yml Просмотреть файл

@@ -19,3 +19,27 @@
- name: Report working Matrix Corporal HTTP gateway
ansible.builtin.debug:
msg: "Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_corporal_self_check_matrix_client_api_url_endpoint_public }}`)"

- when: matrix_corporal_http_api_enabled | bool
block:
- name: Check Matrix Corporal HTTP API
ansible.builtin.uri:
url: "{{ matrix_corporal_self_check_corporal_api_url_endpoint_public }}"
headers:
Authorization: "Bearer {{ matrix_corporal_http_api_auth_token }}"
follow_redirects: none
return_content: false
check_mode: false
register: result_corporal_api
ignore_errors: true
delegate_to: 127.0.0.1
become: false

- name: Fail if Matrix Corporal HTTP API not working
ansible.builtin.fail:
msg: "Failed checking Matrix Corporal is fronting the Matrix Client API at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_corporal_self_check_matrix_client_api_url_endpoint_public }}`). Is matrix-corporal running? Is port 443 open in your firewall? Full error: {{ result_corporal_api }}"
when: "result_corporal_api.failed or result_corporal_api.status != 200"

- name: Report working Matrix Corporal HTTP API
ansible.builtin.debug:
msg: "Matrix Corporal API is working at `{{ matrix_server_fqn_matrix }}` (checked endpoint: `{{ matrix_corporal_self_check_corporal_api_url_endpoint_public }}`)"

Загрузка…
Отмена
Сохранить