From 757d7ae6aa9180a42846a5e57e371395abe5c51a Mon Sep 17 00:00:00 2001 From: SHURAVIN Anatoly Date: Thu, 21 Dec 2023 13:48:03 +0300 Subject: [PATCH] Add tempo datasource support --- .../335-add-datasource-type-tempo.yml | 2 + plugins/modules/grafana_datasource.py | 4 +- .../grafana_datasource/tasks/tempo.yml | 78 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/335-add-datasource-type-tempo.yml create mode 100644 tests/integration/targets/grafana_datasource/tasks/tempo.yml diff --git a/changelogs/fragments/335-add-datasource-type-tempo.yml b/changelogs/fragments/335-add-datasource-type-tempo.yml new file mode 100644 index 00000000..18d34a0a --- /dev/null +++ b/changelogs/fragments/335-add-datasource-type-tempo.yml @@ -0,0 +1,2 @@ +minor_changes: + - Add support for Grafana Tempo datasource type (https://grafana.com/docs/grafana/latest/datasources/tempo/) \ No newline at end of file diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index 0b2d1b64..f743303c 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -46,6 +46,7 @@ - camptocamp-prometheus-alertmanager-datasource - loki - redis-datasource + - tempo type: str ds_url: description: @@ -742,7 +743,8 @@ def setup_module_object(): 'camptocamp-prometheus-alertmanager-datasource', 'sni-thruk-datasource', 'redis-datasource', - 'loki']), + 'loki', + 'tempo']), ds_url=dict(type='str'), access=dict(default='proxy', choices=['proxy', 'direct']), database=dict(type='str', default=""), diff --git a/tests/integration/targets/grafana_datasource/tasks/tempo.yml b/tests/integration/targets/grafana_datasource/tasks/tempo.yml new file mode 100644 index 00000000..5065a6ce --- /dev/null +++ b/tests/integration/targets/grafana_datasource/tasks/tempo.yml @@ -0,0 +1,78 @@ +- name: Create tempo datasource + register: result + grafana_datasource: + name: datasource-tempo + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + org_id: '1' + ds_type: tempo + ds_url: tempo.company.com:3100 + +- debug: + var: result + +- assert: + that: + - result.changed + - "result.msg == 'Datasource datasource-tempo created'" + +- name: Check tempo datasource creation idempotency + register: result + grafana_datasource: + name: datasource-tempo + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + org_id: '1' + ds_type: tempo + ds_url: tempo.company.com:3100 + +- debug: + var: result + +- assert: + that: + - not result.changed + - result.datasource.basicAuth == false + - result.datasource.isDefault == false + - result.datasource.jsonData.tlsAuth == false + - result.datasource.jsonData.tlsAuthWithCACert == false + - result.datasource.secureJsonFields.httpHeaderValue1 == true + - result.datasource.name == 'datasource-tempo' + - result.datasource.orgId == 1 + - result.datasource.type == 'tempo' + - result.datasource.url == 'tempo.company.com:3100' + - result.datasource.withCredentials == false + +- name: Delete tempo datasource + register: result + grafana_datasource: + name: datasource-tempo + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + state: absent + +- debug: + var: result + +- assert: + that: + - result.changed + +- name: Delete tempo datasource + register: result + grafana_datasource: + name: datasource-tempo + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + state: absent + +- debug: + var: result + +- assert: + that: + - not result.changed