summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/grafana/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/grafana/tests/integration')
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/defaults/main.yml9
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/runme.sh5
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-by-org-name.yml84
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml100
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml65
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file-export.yml90
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml44
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml80
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml79
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml62
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/main.yml27
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/defaults/main.yml8
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_datasource/runme.sh5
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/azure.yml117
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml111
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml378
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/errors.yml12
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/influx.yml71
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/issues.yml59
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/loki.yml73
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/main.yml36
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml65
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/quickwit.yml137
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/redis.yml85
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/tempo.yml79
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/thruk.yml69
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/uid.yml255
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/zabbix.yml107
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_folder/defaults/main.yml8
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_folder/runme.sh6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_folder/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/create-delete.yml58
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/main.yml57
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/org.yml7
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/defaults/main.yml8
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/runme.sh5
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml32
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/discord.yml32
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/email.yml42
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/line.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/main.yml50
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml42
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml60
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/teams.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/threema.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml40
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization/defaults/main.yml6
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_organization/runme.sh6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization/tasks/main.yml45
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/defaults/main.yml4
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/runme.sh6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/tasks/main.yml172
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_team/defaults/main.yml8
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_team/runme.sh5
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_team/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/create_user.yml25
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/main.yml273
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_user/defaults/main.yml6
-rwxr-xr-xansible_collections/community/grafana/tests/integration/targets/grafana_user/runme.sh6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_user/site.yml6
-rw-r--r--ansible_collections/community/grafana/tests/integration/targets/grafana_user/tasks/main.yml186
75 files changed, 2461 insertions, 1574 deletions
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/defaults/main.yml
index 8b9c9348a..3edac8598 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/defaults/main.yml
@@ -1,7 +1,4 @@
---
-
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
-
-...
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/runme.sh
new file mode 100755
index 000000000..867afb0d3
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/site.yml
new file mode 100644
index 000000000..c32364ef0
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_dashboard
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_dashboard
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-by-org-name.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-by-org-name.yml
new file mode 100644
index 000000000..a493eb0f8
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-by-org-name.yml
@@ -0,0 +1,84 @@
+---
+- module_defaults:
+ community.grafana.grafana_dashboard:
+ org_name: Main Org.
+ block:
+ - name: Create Dashboard from file by org_name | check mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: true
+ register: dbo_result1
+ - ansible.builtin.assert:
+ that:
+ - dbo_result1.failed == false
+ - dbo_result1.changed == true
+ - dbo_result1.uid is not defined
+ - dbo_result1.msg == 'Dashboard test will be created'
+
+ - name: Create Dashboard from file by org_name | run mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: false
+ register: dbo_result2
+ - ansible.builtin.assert:
+ that:
+ - dbo_result2.failed == false
+ - dbo_result2.changed == true
+ - dbo_result2.uid is defined
+ - dbo_result2.uid | type_debug == "AnsibleUnsafeText"
+ - dbo_result2.msg == 'Dashboard test created'
+
+ - name: Create Dashboard from file by org_name | check mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: true
+ register: dbo_result3
+ - ansible.builtin.assert:
+ that:
+ - dbo_result3.failed == false
+ - dbo_result3.changed == false
+ - dbo_result3.uid is defined
+ - dbo_result3.uid | type_debug == "AnsibleUnsafeText"
+ - dbo_result3.msg == 'Dashboard test unchanged.'
+
+ - name: Create Dashboard from file by org_name | run mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: false
+ register: dbo_result4
+ - ansible.builtin.assert:
+ that:
+ - dbo_result4.failed == false
+ - dbo_result4.changed == false
+ - dbo_result4.uid is defined
+ - dbo_result4.uid | type_debug == "AnsibleUnsafeText"
+ - dbo_result4.msg == 'Dashboard test unchanged.'
+
+ - ansible.builtin.include_tasks:
+ file: delete-dashboard.yml
+ vars:
+ uid_to_delete: '{{ dbo_result4.uid }}'
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml
index 04b17f727..bb4f30e10 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml
@@ -1,33 +1,93 @@
---
-- set_fact:
- dashboard_uid: "{{ result.uid }}"
+- name: Export Dashboard | check mode | uid does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: export
+ path: /tmp/dashboard_export.json
+ overwrite: true
+ uid: "090909090"
+ check_mode: true
+ ignore_errors: true
+ register: de_result1
+- ansible.builtin.assert:
+ that:
+ - de_result1.failed == false
+ - de_result1.changed == false
+ - de_result1.uid is defined
+ - de_result1.uid | type_debug == "AnsibleUnsafeText"
+ - de_result1.uid == "090909090"
+ - de_result1.msg == 'Dashboard ' ~ de_result1.uid ~ ' does not exist.'
-- name: Check export grafana dashboard to file
- grafana_dashboard:
+- name: Export Dashboard | run mode | uid does not exist
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: export
- path: /tmp/dashboard.json
+ path: /tmp/dashboard_export.json
overwrite: true
- uid: "{{ dashboard_uid }}"
- register: result
+ uid: "090909090"
+ check_mode: false
+ ignore_errors: true
+ register: de_result2
+- ansible.builtin.assert:
+ that:
+ - de_result2.failed == false
+ - de_result2.changed == false
+ - de_result2.uid is defined
+ - de_result2.uid | type_debug == "AnsibleUnsafeText"
+ - de_result2.uid == "090909090"
+ - de_result2.msg == 'Dashboard ' ~ de_result2.uid ~ ' does not exist.'
-- debug:
- var: result
+- name: Export Dashboard | check mode | uid exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: export
+ path: /tmp/dashboard_export.json
+ overwrite: true
+ uid: "{{ uid_to_export }}"
+ check_mode: true
+ register: de_result3
+- ansible.builtin.assert:
+ that:
+ - de_result3.failed == false
+ - de_result3.changed == true
+ - de_result3.uid is defined
+ - de_result3.uid | type_debug == "AnsibleUnsafeText"
+ - de_result3.uid == uid_to_export
+ - de_result3.msg == 'Dashboard ' ~ de_result3.uid ~ ' will be exported to /tmp/dashboard_export.json'
-- assert:
+- name: Export Dashboard | run mode | uid exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: export
+ path: /tmp/dashboard_export.json
+ overwrite: true
+ uid: "{{ uid_to_export }}"
+ check_mode: false
+ register: de_result4
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json'"
+ - de_result4.failed == false
+ - de_result4.changed == true
+ - de_result4.uid is defined
+ - de_result4.uid | type_debug == "AnsibleUnsafeText"
+ - de_result4.uid == uid_to_export
+ - de_result4.msg == 'Dashboard ' ~ de_result4.uid ~ ' exported to /tmp/dashboard_export.json'
-- name: Load /tmp/dashboard.json or fail if missing
- set_fact:
- exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard.json').splitlines() }}"
+- name: Export Dashboard | Load /tmp/dashboard_export.json or fail if missing
+ ansible.builtin.set_fact:
+ exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard_export.json').splitlines() }}"
-- name: Assert that exported dashboard contains formatted JSON
- assert:
+- name: Export Dashboard | Assert that exported dashboard contains formatted JSON
+ ansible.builtin.assert:
that:
- - "exported_dashboard_lines | length >= 2"
- - "exported_dashboard_lines[0] == '{'"
- - "exported_dashboard_lines[-1] == '}'"
+ - exported_dashboard_lines | length >= 2
+ - exported_dashboard_lines[0] == '{'
+ - exported_dashboard_lines[-1] == '}'
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml
index f4f3d9f4d..4704002f5 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml
@@ -1,33 +1,38 @@
---
-- name: copy dashboard file
- copy:
- src: "files/dashboard.json"
- dest: "/tmp/dashboard.json"
-
-- block:
- - name: Check import grafana dashboard from file to unknown folder fails
- grafana_dashboard:
- grafana_url: "{{ grafana_url }}"
- grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password }}"
- state: present
- commit_message: Updated by ansible
- path: /tmp/dashboard.json
- overwrite: true
- folder: inexistent
- register: result
- ignore_errors: true
-
-- debug:
- var: result
-
-- set_fact:
- # XXX: Too many quotes of different types to do inline.
- # I did not manage to find a good way of having it inline.
- expected_error: "error : Dashboard folder 'inexistent' does not exist."
+- name: Create Dashboard from file | check mode | folder does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ folder: inexistent
+ check_mode: true
+ register: dfff_result1
+ ignore_errors: true
+- ansible.builtin.assert:
+ that:
+ - dfff_result1.failed == true
+ - dfff_result1.changed == false
+ - "dfff_result1.msg == 'error : Dashboard folder \\'inexistent\\' does not exist.'"
-- assert:
+- name: Create Dashboard from file | run mode | folder does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ folder: inexistent
+ check_mode: false
+ register: dfff_result2
+ ignore_errors: true
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.failed == true"
- - "result.msg == expected_error"
+ - dfff_result2.failed == true
+ - dfff_result2.changed == false
+ - "dfff_result2.msg == 'error : Dashboard folder \\'inexistent\\' does not exist.'"
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file-export.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file-export.yml
new file mode 100644
index 000000000..3d0019c5d
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file-export.yml
@@ -0,0 +1,90 @@
+---
+- name: Create Dashboard from file | Copy dashboard file
+ ansible.builtin.copy:
+ src: files/dashboard.json
+ dest: /tmp/dashboard.json
+
+- name: Create Dashboard from file | check mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: true
+ register: dff_result1
+- ansible.builtin.assert:
+ that:
+ - dff_result1.failed == false
+ - dff_result1.changed == true
+ - dff_result1.uid is not defined
+ - dff_result1.msg == 'Dashboard test will be created'
+
+- name: Create Dashboard from file | run mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: false
+ register: dff_result2
+- ansible.builtin.assert:
+ that:
+ - dff_result2.failed == false
+ - dff_result2.changed == true
+ - dff_result2.uid is defined
+ - dff_result2.uid | type_debug == "AnsibleUnsafeText"
+ - dff_result2.msg == 'Dashboard test created'
+
+- name: Create Dashboard from file | check mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: true
+ register: dff_result3
+- ansible.builtin.assert:
+ that:
+ - dff_result3.failed == false
+ - dff_result3.changed == false
+ - dff_result3.uid is defined
+ - dff_result3.uid | type_debug == "AnsibleUnsafeText"
+ - dff_result3.msg == 'Dashboard test unchanged.'
+
+- name: Create Dashboard from file | run mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ path: /tmp/dashboard.json
+ overwrite: true
+ check_mode: false
+ register: dff_result4
+- ansible.builtin.assert:
+ that:
+ - dff_result4.failed == false
+ - dff_result4.changed == false
+ - dff_result4.uid is defined
+ - dff_result4.uid | type_debug == "AnsibleUnsafeText"
+ - dff_result4.msg == 'Dashboard test unchanged.'
+
+- ansible.builtin.include_tasks:
+ file: dashboard-export.yml
+ vars:
+ uid_to_export: '{{ dff_result4.uid }}'
+
+- ansible.builtin.include_tasks:
+ file: delete-dashboard.yml
+ vars:
+ uid_to_delete: '{{ dff_result4.uid }}'
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml
deleted file mode 100644
index 93df1666a..000000000
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-file.yml
+++ /dev/null
@@ -1,44 +0,0 @@
----
-- name: copy dashboard file
- copy:
- src: "files/dashboard.json"
- dest: "/tmp/dashboard.json"
-
-
-- name: Check import grafana dashboard from file
- grafana_dashboard:
- grafana_url: "{{ grafana_url }}"
- grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password }}"
- state: present
- commit_message: Updated by ansible
- path: /tmp/dashboard.json
- overwrite: true
- register: result
-
-- debug:
- var: result
-
-- assert:
- that:
- - "result.changed == true"
- - "result.msg == 'Dashboard test created'"
-
-- name: Check import grafana dashboard from file idempotency
- grafana_dashboard:
- grafana_url: "{{ grafana_url }}"
- grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password }}"
- state: present
- commit_message: Updated by ansible
- path: /tmp/dashboard.json
- overwrite: true
- register: result
-
-- debug:
- var: result
-
-- assert:
- that:
- - "result.changed == false"
- - "result.msg == 'Dashboard test unchanged.'"
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml
index 3b81ebf71..4de7b4675 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-id.yml
@@ -1,6 +1,6 @@
---
-- name: Check import grafana dashboard from id
- grafana_dashboard:
+- name: Create Dashboard from ID | check mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
@@ -9,18 +9,17 @@
dashboard_id: "6098"
dashboard_revision: "1"
overwrite: true
- register: result
-
-- debug:
- var: result
-
-- assert:
+ check_mode: true
+ register: dfi_result1
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.msg == 'Dashboard Zabbix Host Status created'"
+ - dfi_result1.failed == false
+ - dfi_result1.changed == true
+ - dfi_result1.uid is not defined
+ - dfi_result1.msg == 'Dashboard Zabbix Host Status will be created'
-- name: Check import grafana dashboard from id idempotency
- grafana_dashboard:
+- name: Create Dashboard from ID | run mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
@@ -29,12 +28,57 @@
dashboard_id: "6098"
dashboard_revision: "1"
overwrite: true
- register: result
+ check_mode: false
+ register: dfi_result2
+- ansible.builtin.assert:
+ that:
+ - dfi_result2.failed == false
+ - dfi_result2.changed == true
+ - dfi_result2.uid is defined
+ - dfi_result2.uid | type_debug == "AnsibleUnsafeText"
+ - dfi_result2.msg == 'Dashboard Zabbix Host Status created'
-- debug:
- var: result
+- name: Create Dashboard from ID | check mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ dashboard_id: "6098"
+ dashboard_revision: "1"
+ overwrite: true
+ check_mode: true
+ register: dfi_result3
+- ansible.builtin.assert:
+ that:
+ - dfi_result3.failed == false
+ - dfi_result3.changed == false
+ - dfi_result3.uid is defined
+ - dfi_result3.uid | type_debug == "AnsibleUnsafeText"
+ - dfi_result3.msg == 'Dashboard Zabbix Host Status unchanged.'
-- assert:
+- name: Create Dashboard from ID | run mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ dashboard_id: "6098"
+ dashboard_revision: "1"
+ overwrite: true
+ check_mode: false
+ register: dfi_result4
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.msg == 'Dashboard Zabbix Host Status unchanged.'"
+ - dfi_result4.failed == false
+ - dfi_result4.changed == false
+ - dfi_result4.uid is defined
+ - dfi_result4.uid | type_debug == "AnsibleUnsafeText"
+ - dfi_result4.msg == 'Dashboard Zabbix Host Status unchanged.'
+
+- ansible.builtin.include_tasks:
+ file: delete-dashboard.yml
+ vars:
+ uid_to_delete: '{{ dfi_result4.uid }}'
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml
index 5146fc9a0..abdeacfd0 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-from-url.yml
@@ -1,7 +1,6 @@
---
-
-- name: Check import grafana dashboard from url
- grafana_dashboard:
+- name: Create Dashboard from URL | check mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
@@ -9,18 +8,17 @@
commit_message: Updated by ansible
dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
overwrite: true
- register: result
-
-- debug:
- var: result
-
-- assert:
+ check_mode: true
+ register: dfu_result1
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.msg == 'Dashboard Zabbix Host Status created'"
+ - dfu_result1.failed == false
+ - dfu_result1.changed == true
+ - dfu_result1.uid is not defined
+ - dfu_result1.msg == 'Dashboard Zabbix Host Status will be created'
-- name: Check import grafana dashboard from url idempotency
- grafana_dashboard:
+- name: Create Dashboard from URL | run mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
@@ -28,12 +26,55 @@
commit_message: Updated by ansible
dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
overwrite: true
- register: result
+ check_mode: false
+ register: dfu_result2
+- ansible.builtin.assert:
+ that:
+ - dfu_result2.failed == false
+ - dfu_result2.changed == true
+ - dfu_result2.uid is defined
+ - dfu_result2.uid | type_debug == "AnsibleUnsafeText"
+ - dfu_result2.msg == 'Dashboard Zabbix Host Status created'
-- debug:
- var: result
+- name: Create Dashboard from URL | check mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
+ overwrite: true
+ check_mode: true
+ register: dfu_result3
+- ansible.builtin.assert:
+ that:
+ - dfu_result3.failed == false
+ - dfu_result3.changed == false
+ - dfu_result3.uid is defined
+ - dfu_result3.uid | type_debug == "AnsibleUnsafeText"
+ - dfu_result3.msg == 'Dashboard Zabbix Host Status unchanged.'
-- assert:
+- name: Create Dashboard from URL | run mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: present
+ commit_message: Updated by ansible
+ dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
+ overwrite: true
+ check_mode: false
+ register: dfu_result4
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.msg == 'Dashboard Zabbix Host Status unchanged.'"
+ - dfu_result4.failed == false
+ - dfu_result4.changed == false
+ - dfu_result4.uid is defined
+ - dfu_result4.uid | type_debug == "AnsibleUnsafeText"
+ - dfu_result4.msg == 'Dashboard Zabbix Host Status unchanged.'
+
+- ansible.builtin.include_tasks:
+ file: delete-dashboard.yml
+ vars:
+ uid_to_delete: '{{ dfu_result4.uid }}' \ No newline at end of file
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml
index 2013324fb..b2d27fdc8 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml
@@ -1,16 +1,60 @@
-- name: Check delete dashboard is working
- grafana_dashboard:
+---
+- name: Delete dashboard | check mode | dashboard exists
+ community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
- uid: "{{ result.uid }}"
- register: result
+ uid: "{{ uid_to_delete }}"
+ check_mode: true
+ register: dd_result1
+- ansible.builtin.assert:
+ that:
+ - dd_result1.failed == false
+ - dd_result1.changed == true
+ - dd_result1.msg == 'Dashboard ' ~ dd_result1.uid ~ ' will be deleted'
+
+- name: Delete dashboard | run mode | dashboard exists
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+ uid: "{{ uid_to_delete }}"
+ check_mode: false
+ register: dd_result2
+- ansible.builtin.assert:
+ that:
+ - dd_result2.failed == false
+ - dd_result2.changed == true
+ - dd_result2.msg == 'Dashboard ' ~ dd_result2.uid ~ ' deleted'
-- debug:
- var: result
+- name: Delete dashboard | check mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+ uid: "{{ uid_to_delete }}"
+ check_mode: true
+ register: dd_result1
+- ansible.builtin.assert:
+ that:
+ - dd_result1.failed == false
+ - dd_result1.changed == false
+ - dd_result1.msg == 'Dashboard ' ~ dd_result1.uid ~ ' does not exist.'
-- assert:
+- name: Delete dashboard | run mode | dashboard does not exist
+ community.grafana.grafana_dashboard:
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+ uid: "{{ uid_to_delete }}"
+ check_mode: false
+ register: dd_result2
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.msg == 'Dashboard {{ result.uid }} deleted'"
+ - dd_result2.failed == false
+ - dd_result2.changed == false
+ - dd_result2.msg == 'Dashboard ' ~ dd_result2.uid ~ ' does not exist.' \ No newline at end of file
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/main.yml
index 4d9138fcf..86e756e95 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/main.yml
@@ -1,7 +1,20 @@
-- block:
- - include: dashboard-from-url.yml
- - include: delete-dashboard.yml
- - include: dashboard-from-id.yml
- - include: dashboard-from-file.yml
- - include: dashboard-export.yml
- - include: dashboard-folder-destination.yml
+---
+- name: Create dashboard from url
+ ansible.builtin.include_tasks:
+ file: dashboard-from-url.yml
+
+- name: Create dashboard from id
+ ansible.builtin.include_tasks:
+ file: dashboard-from-id.yml
+
+- name: Create dashboard from file and export
+ ansible.builtin.include_tasks:
+ file: dashboard-from-file-export.yml
+
+- name: Create dashboard from file by org_name
+ ansible.builtin.include_tasks:
+ file: dashboard-by-org-name.yml
+
+- name: Create dashboard from file in non existing folder
+ ansible.builtin.include_tasks:
+ file: dashboard-folder-destination.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/defaults/main.yml
index 8b9c9348a..4abf9bb43 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/defaults/main.yml
@@ -1,7 +1,5 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
-
-...
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/runme.sh
new file mode 100755
index 000000000..867afb0d3
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/site.yml
new file mode 100644
index 000000000..c8374dcdd
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_datasource
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_datasource
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/azure.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/azure.yml
index a96691893..0dbd94963 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/azure.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/azure.yml
@@ -1,11 +1,12 @@
+---
- name: Create azure datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-azure
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: grafana-azure-monitor-datasource
ds_url: http://example.com
azure_client: client1
@@ -13,38 +14,38 @@
azure_secret: secret1
azure_cloud: azuremonitor
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-azure created'"
- - result.datasource.access == 'proxy'
- - result.datasource.basicAuth == false
- - result.datasource.database == ''
- - result.datasource.isDefault == false
- - result.datasource.jsonData.clientId == 'client1'
- - result.datasource.jsonData.cloudName == 'azuremonitor'
- - result.datasource.jsonData.tenantId == 'tenant1'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-azure'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'grafana-azure-monitor-datasource'
- - result.datasource.url == 'http://example.com'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - result.changed
+ - result.msg == 'Datasource datasource-azure created'
+ - result.datasource.access == 'proxy'
+ - result.datasource.basicAuth == false
+ - result.datasource.database == ''
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.clientId == 'client1'
+ - result.datasource.jsonData.cloudName == 'azuremonitor'
+ - result.datasource.jsonData.tenantId == 'tenant1'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-azure'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'grafana-azure-monitor-datasource'
+ - result.datasource.url == 'http://example.com'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Check azure datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-azure
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: grafana-azure-monitor-datasource
ds_url: http://example.com
azure_client: client1
@@ -52,37 +53,37 @@
azure_secret: secret1
azure_cloud: azuremonitor
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.basicAuth == false
- - result.datasource.database == ''
- - result.datasource.isDefault == false
- - result.datasource.jsonData.clientId == 'client1'
- - result.datasource.jsonData.cloudName == 'azuremonitor'
- - result.datasource.jsonData.tenantId == 'tenant1'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-azure'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'grafana-azure-monitor-datasource'
- - result.datasource.url == 'http://example.com'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.basicAuth == false
+ - result.datasource.database == ''
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.clientId == 'client1'
+ - result.datasource.jsonData.cloudName == 'azuremonitor'
+ - result.datasource.jsonData.tenantId == 'tenant1'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-azure'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'grafana-azure-monitor-datasource'
+ - result.datasource.url == 'http://example.com'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete azure datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-azure
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: grafana-azure-monitor-datasource
ds_url: http://example.com
azure_client: client1
@@ -91,22 +92,22 @@
azure_cloud: azuremonitor
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-azure deleted.'"
+ - result.changed
+ - result.msg == 'Datasource datasource-azure deleted.'
- name: Delete azure datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-azure
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: grafana-azure-monitor-datasource
ds_url: http://example.com
azure_client: client1
@@ -115,9 +116,9 @@
azure_cloud: azuremonitor
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml
index 50268ea8f..79408b68b 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/cloudwatch.yml
@@ -1,11 +1,12 @@
+---
- name: Create cloudwatch datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-cloudwatch
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: cloudwatch
ds_url: http://monitoring.us-west-1.amazonaws.com
aws_auth_type: keys
@@ -14,38 +15,38 @@
aws_secret_key: mel10n
aws_custom_metrics_namespaces: n1,n2
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-cloudwatch created'"
- - result.datasource.access == 'proxy'
- - result.datasource.basicAuth == false
- - result.datasource.database == ''
- - result.datasource.isDefault == false
- - result.datasource.jsonData.authType == 'keys'
- - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2'
- - result.datasource.jsonData.defaultRegion == 'us-west-1'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-cloudwatch'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'cloudwatch'
- - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - result.changed
+ - result.msg == 'Datasource datasource-cloudwatch created'
+ - result.datasource.access == 'proxy'
+ - result.datasource.basicAuth == false
+ - result.datasource.database == ''
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.authType == 'keys'
+ - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2'
+ - result.datasource.jsonData.defaultRegion == 'us-west-1'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-cloudwatch'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'cloudwatch'
+ - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Check cloudwatch datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-cloudwatch
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: cloudwatch
ds_url: http://monitoring.us-west-1.amazonaws.com
aws_auth_type: keys
@@ -54,58 +55,58 @@
aws_secret_key: mel10n
aws_custom_metrics_namespaces: n1,n2
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.basicAuth == false
- - result.datasource.database == ''
- - result.datasource.isDefault == false
- - result.datasource.jsonData.authType == 'keys'
- - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2'
- - result.datasource.jsonData.defaultRegion == 'us-west-1'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-cloudwatch'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'cloudwatch'
- - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.basicAuth == false
+ - result.datasource.database == ''
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.authType == 'keys'
+ - result.datasource.jsonData.customMetricsNamespaces == 'n1,n2'
+ - result.datasource.jsonData.defaultRegion == 'us-west-1'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-cloudwatch'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'cloudwatch'
+ - result.datasource.url == 'http://monitoring.us-west-1.amazonaws.com'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete cloudwatch datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-cloudwatch
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-cloudwatch deleted.'"
+ - result.changed
+ - result.msg == 'Datasource datasource-cloudwatch deleted.'
- name: Delete cloudwatch datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-cloudwatch
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml
index 73b258426..ff05b93f5 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml
@@ -1,313 +1,313 @@
---
- name: Create elasticsearch datasource with legacy elasticsearch format
register: result
- grafana_datasource:
- name: "datasource/elasticLegacy"
- uid: "myuid"
+ community.grafana.grafana_datasource:
+ name: datasource/elasticLegacy
+ uid: myuid
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.company.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
es_version: 56
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == 56
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elasticLegacy'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.company.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - "result.msg == 'Datasource datasource/elasticLegacy created'"
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == 56
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elasticLegacy'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.company.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.msg == 'Datasource datasource/elasticLegacy created'
- name: Create elasticsearch datasource with new elsaticsearch version format
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.company.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
- es_version: "7.10+"
+ es_version: 7.10+
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == "7.10.0"
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.company.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - "result.msg == 'Datasource datasource/elastic created'"
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == "7.10.0"
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.company.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.msg == 'Datasource datasource/elastic created'
- name: Check elasticsearch datasource creation idempotency
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.company.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
- es_version: "7.10+"
+ es_version: 7.10+
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == '7.10.0'
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.company.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
+ - not result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == '7.10.0'
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.company.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
-- name: update elasticsearch datasource creation
+- name: Update elasticsearch datasource creation
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.example.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
- es_version: "7.10+"
+ es_version: 7.10+
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == '7.10.0'
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.example.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == '7.10.0'
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.example.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
-- name: update elasticsearch datasource (ignoring secureJsonData)
+- name: Update elasticsearch datasource (ignoring secureJsonData)
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.example.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
- es_version: "7.10+"
+ es_version: 7.10+
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
enforce_secure_data: false
additional_json_data:
- nonSecureTest: "nonsecure"
+ nonSecureTest: nonsecure
additional_secure_json_data:
- secureTest: "secure"
+ secureTest: secure
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == '7.10.0'
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.example.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - result.datasource.jsonData.nonSecureTest == 'nonsecure'
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == '7.10.0'
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.example.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.datasource.jsonData.nonSecureTest == 'nonsecure'
-- name: update elasticsearch datasource (including secureJsonData)
+- name: Update elasticsearch datasource (including secureJsonData)
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.example.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
- es_version: "7.10+"
+ es_version: 7.10+
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
enforce_secure_data: true
additional_json_data:
- nonSecureTest: "nonsecure"
+ nonSecureTest: nonsecure
additional_secure_json_data:
- secureTest: "secure"
+ secureTest: secure
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == '7.10.0'
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.example.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - result.datasource.jsonData.nonSecureTest == 'nonsecure'
- - result.datasource.secureJsonFields.secureTest == true
- - result.diff.after.secureJsonData is defined
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == '7.10.0'
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.example.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.datasource.jsonData.nonSecureTest == 'nonsecure'
+ - result.datasource.secureJsonFields.secureTest == true
+ - result.diff.after.secureJsonData is defined
- name: Delete elasticsearch datasource
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete elasticsearch datasource (idempotency)
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/errors.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/errors.yml
index 731a19d8f..779b4724d 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/errors.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/errors.yml
@@ -1,18 +1,18 @@
---
- name: Create datasource without `ds_type` and `ds_url` (expect failure)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-postgres
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
ignore_errors: true
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.failed
- - "result.msg == 'state is present but all of the following are missing: ds_type, ds_url'"
+ - not result.changed
+ - result.failed
+ - "result.msg == 'state is present but all of the following are missing: ds_type, ds_url'"
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/influx.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/influx.yml
index da61833f6..7952bec6b 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/influx.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/influx.yml
@@ -1,88 +1,89 @@
+---
- name: Create influxdb datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-influxdb
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: influxdb
ds_url: https://influx.company.com:8086
database: telegraf
- time_interval: '>10s'
+ time_interval: ">10s"
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-influxdb created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-influxdb created'
- name: Check influxdb datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-influxdb
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: influxdb
ds_url: https://influx.company.com:8086
database: telegraf
- time_interval: '>10s'
+ time_interval: ">10s"
tls_ca_cert: /etc/ssl/certs/ca.pem
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.basicAuth == false
- - result.datasource.access == 'proxy'
- - result.datasource.database == 'telegraf'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.timeInterval == '>10s'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource-influxdb'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'influxdb'
- - result.datasource.url == 'https://influx.company.com:8086'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.basicAuth == false
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == 'telegraf'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.timeInterval == '>10s'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource-influxdb'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'influxdb'
+ - result.datasource.url == 'https://influx.company.com:8086'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete influxdb datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-influxdb
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete influxdb datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-influxdb
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/issues.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/issues.yml
index f80677d8d..3b4df5a71 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/issues.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/issues.yml
@@ -1,46 +1,43 @@
---
-
-- name: test datasource name with slash
+- name: Test datasource name with slash
register: result
- grafana_datasource:
- name: "datasource/elastic"
+ community.grafana.grafana_datasource:
+ name: datasource/elastic
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: elasticsearch
ds_url: https://elastic.company.com:9200
- database: '[logstash_]YYYY.MM.DD'
+ database: "[logstash_]YYYY.MM.DD"
basic_auth_user: grafana
- basic_auth_password: '******'
- time_field: '@timestamp'
+ basic_auth_password: "******"
+ time_field: "@timestamp"
time_interval: 1m
interval: Daily
es_version: 56
max_concurrent_shard_requests: 42
tls_ca_cert: /etc/ssl/certs/ca.pem
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.basicAuth
- - result.datasource.basicAuthUser == 'grafana'
- - result.datasource.access == 'proxy'
- - result.datasource.database == '[logstash_]YYYY.MM.DD'
- - not result.datasource.isDefault
- - result.datasource.jsonData.esVersion == 56
- - result.datasource.jsonData.interval == 'Daily'
- - result.datasource.jsonData.maxConcurrentShardRequests == 42
- - result.datasource.jsonData.timeField == '@timestamp'
- - not result.datasource.jsonData.tlsAuth
- - not result.datasource.jsonData.tlsAuthWithCACert
- - result.datasource.name == 'datasource/elastic'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'elasticsearch'
- - result.datasource.url == 'https://elastic.company.com:9200'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - "result.msg == 'Datasource datasource/elastic created'"
-
-...
+ - result.changed
+ - result.datasource.basicAuth
+ - result.datasource.basicAuthUser == 'grafana'
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == '[logstash_]YYYY.MM.DD'
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.esVersion == 56
+ - result.datasource.jsonData.interval == 'Daily'
+ - result.datasource.jsonData.maxConcurrentShardRequests == 42
+ - result.datasource.jsonData.timeField == '@timestamp'
+ - not result.datasource.jsonData.tlsAuth
+ - not result.datasource.jsonData.tlsAuthWithCACert
+ - result.datasource.name == 'datasource/elastic'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'elasticsearch'
+ - result.datasource.url == 'https://elastic.company.com:9200'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.msg == 'Datasource datasource/elastic created'
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/loki.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/loki.yml
index 68eca9802..a501b99d2 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/loki.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/loki.yml
@@ -1,82 +1,83 @@
+---
- name: Create loki datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-loki
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
- org_id: '1'
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
ds_type: loki
ds_url: https://loki.company.com:3100
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-loki created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-loki created'
- name: Check loki datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-loki
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: loki
ds_url: https://loki.company.com:3100
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.basicAuth == false
- - result.datasource.access == 'proxy'
- - result.datasource.database == ''
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-loki'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'loki'
- - result.datasource.url == 'https://loki.company.com:3100'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.basicAuth == false
+ - result.datasource.access == 'proxy'
+ - result.datasource.database == ''
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-loki'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'loki'
+ - result.datasource.url == 'https://loki.company.com:3100'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete loki datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-loki
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-loki deleted.'"
+ - result.changed
+ - result.msg == 'Datasource datasource-loki deleted.'
- name: Delete loki datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-loki
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/main.yml
index b5798e9a8..0b3ea4cd6 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/main.yml
@@ -1,16 +1,24 @@
---
-
- block:
- - include: errors.yml
- - include: elastic.yml
- - include: influx.yml
- - include: postgres.yml
- - include: cloudwatch.yml
- - include: thruk.yml
- - include: loki.yml
- - include: zabbix.yml
- - include: redis.yml
- - include: azure.yml
- - include: uid.yml
-
-...
+ - ansible.builtin.include_tasks:
+ file: errors.yml
+ - ansible.builtin.include_tasks:
+ file: elastic.yml
+ - ansible.builtin.include_tasks:
+ file: influx.yml
+ - ansible.builtin.include_tasks:
+ file: postgres.yml
+ - ansible.builtin.include_tasks:
+ file: cloudwatch.yml
+ - ansible.builtin.include_tasks:
+ file: thruk.yml
+ - ansible.builtin.include_tasks:
+ file: loki.yml
+ - ansible.builtin.include_tasks:
+ file: zabbix.yml
+ - ansible.builtin.include_tasks:
+ file: redis.yml
+ - ansible.builtin.include_tasks:
+ file: azure.yml
+ - ansible.builtin.include_tasks:
+ file: uid.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml
index 80221f012..b07bc752b 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml
@@ -1,11 +1,12 @@
+---
- name: Create postgres datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-postgres
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: postgres
ds_url: postgres.company.com:5432
database: db
@@ -15,22 +16,22 @@
additional_json_data:
timescaledb: true
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-postgres created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-postgres created'
- name: Check postgres datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-postgres
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: postgres
ds_url: postgres.company.com:5432
database: db
@@ -40,54 +41,54 @@
additional_json_data:
timescaledb: true
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.basicAuth == false
- - result.datasource.database == 'db'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.sslmode == 'verify-full'
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.jsonData.timescaledb == true
- - result.datasource.name == 'datasource-postgres'
- - result.datasource.orgId == 1
- - result.datasource.type == 'postgres'
- - result.datasource.url == 'postgres.company.com:5432'
- - result.datasource.user == 'postgres'
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.basicAuth == false
+ - result.datasource.database == 'db'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.sslmode == 'verify-full'
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.jsonData.timescaledb == true
+ - result.datasource.name == 'datasource-postgres'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'postgres'
+ - result.datasource.url == 'postgres.company.com:5432'
+ - result.datasource.user == 'postgres'
+ - result.datasource.withCredentials == false
- name: Delete postgres datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-postgres
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete postgres datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-postgres
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/quickwit.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/quickwit.yml
new file mode 100644
index 000000000..8221dcb42
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/quickwit.yml
@@ -0,0 +1,137 @@
+---
+- name: Create Quickwit datasource
+ register: result
+ community.grafana.grafana_datasource:
+ name: Quickwit
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
+ ds_type: quickwit-quickwit-datasource
+ ds_url: http://localhost:7280/api/v1
+ additional_json_data:
+ index: hdfs-logs
+ timeField: timestamp
+ timeOutputFormat: unix_timestamp_secs
+ logMessageField: body
+ logLevelField: severity_text
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.database == ''
+ - result.datasource.name == 'Quickwit'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'quickwit-quickwit-datasource'
+ - result.datasource.url == 'http://localhost:7280/api/v1'
+ - result.msg == 'Datasource Quickwit created'
+ - result.datasource.jsonData.index == 'hdfs-logs'
+ - result.datasource.jsonData.timeField == 'timestamp'
+ - result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_secs'
+ - result.datasource.jsonData.logMessageField == 'body'
+ - result.datasource.jsonData.logLevelField == 'severity_text'
+
+- name: Check Quickwit datasource creation (idempotency)
+ register: result
+ community.grafana.grafana_datasource:
+ name: Quickwit
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
+ ds_type: quickwit-quickwit-datasource
+ ds_url: http://localhost:7280/api/v1
+ additional_json_data:
+ index: hdfs-logs
+ timeField: timestamp
+ timeOutputFormat: unix_timestamp_secs
+ logMessageField: body
+ logLevelField: severity_text
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.database == ''
+ - result.datasource.name == 'Quickwit'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'quickwit-quickwit-datasource'
+ - result.datasource.url == 'http://localhost:7280/api/v1'
+ - result.msg == 'Datasource Quickwit created'
+ - result.datasource.jsonData.index == 'hdfs-logs'
+ - result.datasource.jsonData.timeField == 'timestamp'
+ - result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_secs'
+ - result.datasource.jsonData.logMessageField == 'body'
+ - result.datasource.jsonData.logLevelField == 'severity_text'
+
+- name: Update Quickwit datasource
+ register: result
+ community.grafana.grafana_datasource:
+ name: Quickwit
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ org_id: "1"
+ ds_type: quickwit-quickwit-datasource
+ ds_url: http://quickwit-url:7280/api/v1
+ additional_json_data:
+ index: hdfs-logs
+ timeField: timestamp
+ timeOutputFormat: unix_timestamp_millis
+ logMessageField: body
+ logLevelField: severity_text
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.database == ''
+ - result.datasource.name == 'Quickwit'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'quickwit-quickwit-datasource'
+ - result.datasource.url == 'http://quickwit-url:7280/api/v1'
+ - result.msg == 'Datasource Quickwit created'
+ - result.datasource.jsonData.index == 'hdfs-logs'
+ - result.datasource.jsonData.timeField == 'timestamp'
+ - result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_millis'
+ - result.datasource.jsonData.logMessageField == 'body'
+ - result.datasource.jsonData.logLevelField == 'severity_text'
+
+- name: Delete Quickwit datasource
+ register: result
+ community.grafana.grafana_datasource:
+ name: Quickwit
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed
+
+- name: Delete Quickwit datasource (idempotency)
+ register: result
+ community.grafana.grafana_datasource:
+ name: Quickwit
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/redis.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/redis.yml
index 933695354..dc39be64e 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/redis.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/redis.yml
@@ -1,101 +1,102 @@
+---
- name: Create redis datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-redis
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: redis-datasource
ds_url: https://redis.company.com:6379
time_interval: 1m
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.access == 'proxy'
- - not result.datasource.isDefault
- - result.datasource.name == 'datasource-redis'
- - result.datasource.orgId == 1
- - result.datasource.type == 'redis-datasource'
- - result.datasource.url == 'https://redis.company.com:6379'
- - "result.msg == 'Datasource datasource-redis created'"
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.name == 'datasource-redis'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'redis-datasource'
+ - result.datasource.url == 'https://redis.company.com:6379'
+ - result.msg == 'Datasource datasource-redis created'
- name: Check redis-datasource datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-redis
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: redis-datasource
ds_url: https://redis.company.com:6379
time_interval: 1m
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.access == 'proxy'
- - not result.datasource.isDefault
- - result.datasource.name == 'datasource-redis'
- - result.datasource.orgId == 1
- - result.datasource.type == 'redis-datasource'
- - result.datasource.url == 'https://redis.company.com:6379'
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.name == 'datasource-redis'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'redis-datasource'
+ - result.datasource.url == 'https://redis.company.com:6379'
-- name: update redis-datasource datasource creation
+- name: Update redis-datasource datasource creation
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-redis
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: redis-datasource
ds_url: https://redisnew.company.com:6379
time_interval: 1m
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.access == 'proxy'
- - not result.datasource.isDefault
- - result.datasource.name == 'datasource-redis'
- - result.datasource.orgId == 1
- - result.datasource.type == 'redis-datasource'
- - result.datasource.url == 'https://redisnew.company.com:6379'
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - not result.datasource.isDefault
+ - result.datasource.name == 'datasource-redis'
+ - result.datasource.orgId == 1
+ - result.datasource.type == 'redis-datasource'
+ - result.datasource.url == 'https://redisnew.company.com:6379'
-- name: Delete redis-datasource datasource
+- name: Delete redis-datasource datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-redis
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete redis-datasource datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-redis
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/tempo.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/tempo.yml
new file mode 100644
index 000000000..51ab52513
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/tempo.yml
@@ -0,0 +1,79 @@
+---
+- name: Create tempo datasource
+ register: result
+ community.grafana.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
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed
+ - result.msg == 'Datasource datasource-tempo created'
+
+- name: Check tempo datasource creation idempotency
+ register: result
+ community.grafana.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
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.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
+ community.grafana.grafana_datasource:
+ name: datasource-tempo
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed
+
+- name: Delete tempo datasource
+ register: result
+ community.grafana.grafana_datasource:
+ name: datasource-tempo
+ grafana_url: "{{ grafana_url }}"
+ grafana_user: "{{ grafana_username }}"
+ grafana_password: "{{ grafana_password }}"
+ state: absent
+
+- ansible.builtin.debug:
+ var: result
+
+- ansible.builtin.assert:
+ that:
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/thruk.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/thruk.yml
index 3ecc92d94..74f7c4dfa 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/thruk.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/thruk.yml
@@ -1,78 +1,79 @@
+---
- name: Create thruk datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-thruk
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
org_id: "1"
ds_type: sni-thruk-datasource
- ds_url: "https://thruk.company.com/sitename/thruk"
- tls_skip_verify: yes
- validate_certs: no
+ ds_url: https://thruk.company.com/sitename/thruk
+ tls_skip_verify: true
+ validate_certs: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-thruk created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-thruk created'
- name: Check thruk datasource creation idempotency
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-thruk
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: sni-thruk-datasource
- ds_url: "https://thruk.company.com/sitename/thruk"
- tls_skip_verify: yes
- validate_certs: no
+ ds_url: https://thruk.company.com/sitename/thruk
+ tls_skip_verify: true
+ validate_certs: false
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.basicAuth == false
- - result.datasource.access == 'proxy'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.jsonData.tlsAuthWithCACert == false
- - result.datasource.name == 'datasource-thruk'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'sni-thruk-datasource'
- - result.datasource.url == 'https://thruk.company.com/sitename/thruk'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.basicAuth == false
+ - result.datasource.access == 'proxy'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.jsonData.tlsAuthWithCACert == false
+ - result.datasource.name == 'datasource-thruk'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'sni-thruk-datasource'
+ - result.datasource.url == 'https://thruk.company.com/sitename/thruk'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete thruk datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-thruk
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete thruk datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-thruk
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/uid.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/uid.yml
index 71102a074..7a472b42f 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/uid.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/uid.yml
@@ -1,253 +1,254 @@
+---
- name: Create datasource with uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-with-uid
uid: uid1
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-with-uid created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-with-uid created'
- name: Create datasource without uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-without-uid
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - "result.msg == 'Datasource datasource-without-uid created'"
+ - result.changed
+ - result.msg == 'Datasource datasource-without-uid created'
- name: Check datasource creation idempotency with uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-with-uid
uid: uid1
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.name == 'datasource-with-uid'
- - result.datasource.uid == 'uid1'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'prometheus'
- - result.datasource.url == 'https://prometheus.company.com:8086'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.name == 'datasource-with-uid'
+ - result.datasource.uid == 'uid1'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'prometheus'
+ - result.datasource.url == 'https://prometheus.company.com:8086'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Check datasource creation idempotency without uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-without-uid
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.name == 'datasource-without-uid'
- - result.datasource.uid
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'prometheus'
- - result.datasource.url == 'https://prometheus.company.com:8086'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - not result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.name == 'datasource-without-uid'
+ - result.datasource.uid
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'prometheus'
+ - result.datasource.url == 'https://prometheus.company.com:8086'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Set uid for datasource with random uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-without-uid
uid: uid3
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.name == 'datasource-without-uid'
- - result.datasource.uid == 'uid3'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'prometheus'
- - result.datasource.url == 'https://prometheus.company.com:8086'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.name == 'datasource-without-uid'
+ - result.datasource.uid == 'uid3'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'prometheus'
+ - result.datasource.url == 'https://prometheus.company.com:8086'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Change uid for datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-with-uid
uid: uid2
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - result.datasource.access == 'proxy'
- - result.datasource.isDefault == false
- - result.datasource.jsonData.tlsAuth == false
- - result.datasource.name == 'datasource-with-uid'
- - result.datasource.uid == 'uid2'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'prometheus'
- - result.datasource.url == 'https://prometheus.company.com:8086'
- - result.datasource.user == ''
- - result.datasource.withCredentials == false
+ - result.changed
+ - result.datasource.access == 'proxy'
+ - result.datasource.isDefault == false
+ - result.datasource.jsonData.tlsAuth == false
+ - result.datasource.name == 'datasource-with-uid'
+ - result.datasource.uid == 'uid2'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'prometheus'
+ - result.datasource.url == 'https://prometheus.company.com:8086'
+ - result.datasource.user == ''
+ - result.datasource.withCredentials == false
- name: Delete datasource-with-uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-with-uid
uid: uid1
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete datasource-without-uid
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-without-uid
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete datasource-with-uid (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-with-uid
uid: uid1
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: prometheus
ds_url: https://prometheus.company.com:8086
- basic_auth_user: "admin"
- basic_auth_password: "admin"
- validate_certs: False
- is_default: no
+ basic_auth_user: admin
+ basic_auth_password: admin
+ validate_certs: false
+ is_default: false
state: absent
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/zabbix.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/zabbix.yml
index c8a8236bf..d238efb3e 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/zabbix.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/zabbix.yml
@@ -1,114 +1,115 @@
+---
- name: Create zabbix datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-zabbix
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: alexanderzobnin-zabbix-datasource
ds_url: https://zabbix.company.com
zabbix_user: grafana
- zabbix_password: '******'
+ zabbix_password: "******"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - not result.datasource.isDefault
- - result.datasource.jsonData.username == 'grafana'
- - result.datasource.name == 'datasource-zabbix'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
- - result.datasource.url == 'https://zabbix.company.com'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - "result.msg == 'Datasource datasource-zabbix created'"
+ - result.changed
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.username == 'grafana'
+ - result.datasource.name == 'datasource-zabbix'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
+ - result.datasource.url == 'https://zabbix.company.com'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.msg == 'Datasource datasource-zabbix created'
- name: Create zabbix datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-zabbix
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: alexanderzobnin-zabbix-datasource
ds_url: https://zabbix.company.com
zabbix_user: grafana
- zabbix_password: '******'
+ zabbix_password: "******"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
- - not result.datasource.isDefault
- - result.datasource.jsonData.username == 'grafana'
- - result.datasource.name == 'datasource-zabbix'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
- - result.datasource.url == 'https://zabbix.company.com'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
+ - not result.changed
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.username == 'grafana'
+ - result.datasource.name == 'datasource-zabbix'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
+ - result.datasource.url == 'https://zabbix.company.com'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
- name: Update zabbix datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-zabbix
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
- org_id: '1'
+ org_id: "1"
ds_type: alexanderzobnin-zabbix-datasource
ds_url: https://zabbix.example.com
zabbix_user: grafana
- zabbix_password: '******'
+ zabbix_password: "******"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
- - not result.datasource.isDefault
- - result.datasource.jsonData.username == 'grafana'
- - result.datasource.name == 'datasource-zabbix'
- - result.datasource.orgId == 1
- - ('password' not in result.datasource) or (result.datasource.password == '')
- - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
- - result.datasource.url == 'https://zabbix.example.com'
- - result.datasource.user == ''
- - not result.datasource.withCredentials
- - "result.msg == 'Datasource datasource-zabbix updated'"
+ - result.changed
+ - not result.datasource.isDefault
+ - result.datasource.jsonData.username == 'grafana'
+ - result.datasource.name == 'datasource-zabbix'
+ - result.datasource.orgId == 1
+ - ('password' not in result.datasource) or (result.datasource.password == '')
+ - result.datasource.type == 'alexanderzobnin-zabbix-datasource'
+ - result.datasource.url == 'https://zabbix.example.com'
+ - result.datasource.user == ''
+ - not result.datasource.withCredentials
+ - result.msg == 'Datasource datasource-zabbix updated'
- name: Delete zabbix datasource
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-zabbix
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - result.changed
+ - result.changed
- name: Delete zabbix datasource (idempotency)
register: result
- grafana_datasource:
+ community.grafana.grafana_datasource:
name: datasource-zabbix
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent
-- assert:
+- ansible.builtin.assert:
that:
- - not result.changed
+ - not result.changed
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/defaults/main.yml
index 8b9c9348a..4abf9bb43 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/defaults/main.yml
@@ -1,7 +1,5 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
-
-...
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/runme.sh
new file mode 100755
index 000000000..9daa487db
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml --check
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/site.yml
new file mode 100644
index 000000000..2041400ea
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_folder
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_folder
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/create-delete.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/create-delete.yml
new file mode 100644
index 000000000..c818c2ef1
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/create-delete.yml
@@ -0,0 +1,58 @@
+---
+- name: Create a Folder
+ community.grafana.grafana_folder:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ title: grafana_working_group
+ state: present
+ register: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.folder.title == 'grafana_working_group'
+ when: not ansible_check_mode
+
+- name: Test folder creation idempotency
+ community.grafana.grafana_folder:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ title: grafana_working_group
+ state: present
+ register: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.folder.title == 'grafana_working_group'
+ when: not ansible_check_mode
+
+- name: Delete a Folder
+ community.grafana.grafana_folder:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ title: grafana_working_group
+ state: absent
+ register: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ when: not ansible_check_mode
+
+- name: Test folder deletion idempotency
+ community.grafana.grafana_folder:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ title: grafana_working_group
+ state: absent
+ register: result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: not ansible_check_mode
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/main.yml
index c6a520560..0ac91f375 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/main.yml
@@ -1,55 +1,6 @@
---
+- name: Folder creation and deletion
+ ansible.builtin.include_tasks: create-delete.yml
-- name: Create a Folder
- grafana_folder:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- title: "grafana_working_group"
- state: present
- register: result
-
-- assert:
- that:
- - "result.changed == true"
- - "result.folder.title == 'grafana_working_group'"
-
-- name: Test folder creation idempotency
- grafana_folder:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- title: "grafana_working_group"
- state: present
- register: result
-
-- assert:
- that:
- - "result.changed == false"
- - "result.folder.title == 'grafana_working_group'"
-
-- name: Delete a Folder
- grafana_folder:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- title: "grafana_working_group"
- state: absent
- register: result
-
-- assert:
- that:
- - "result.changed == true"
-
-- name: Test folder deletion idempotency
- grafana_folder:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- title: "grafana_working_group"
- state: absent
- register: result
-
-- assert:
- that:
- - "result.changed == false"
+- name: Folder creation and deletion for organization
+ ansible.builtin.include_tasks: org.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/org.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/org.yml
new file mode 100644
index 000000000..f30d48c14
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_folder/tasks/org.yml
@@ -0,0 +1,7 @@
+---
+- module_defaults:
+ community.grafana.grafana_folder:
+ org_name: Main Org.
+ block:
+ - name: Folder creation and deletion
+ ansible.builtin.include_tasks: create-delete.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/defaults/main.yml
index 8b9c9348a..4abf9bb43 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/defaults/main.yml
@@ -1,7 +1,5 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
-
-...
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/runme.sh
new file mode 100755
index 000000000..867afb0d3
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/site.yml
new file mode 100644
index 000000000..e20f44e32
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_notification_channel
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_notification_channel
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml
index 7279e313b..80d2f07d8 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/dingding.yml
@@ -1,19 +1,19 @@
---
- name: Create dingding notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: dingding
name: dingding
type: dingding
dingding_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == True
- result.channel.name == "dingding"
@@ -22,19 +22,19 @@
- name: Create dingding notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: dingding
name: dingding
type: dingding
dingding_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == False
- result.channel.name == "dingding"
@@ -43,32 +43,32 @@
- name: Delete dingding notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: dingding
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == True
- name: Delete dingding notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: dingding
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/discord.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/discord.yml
index 29cfece70..30c70d63e 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/discord.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/discord.yml
@@ -1,19 +1,19 @@
---
- name: Create discord notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: discord
name: discord
type: discord
discord_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == True
- result.channel.name == "discord"
@@ -22,19 +22,19 @@
- name: Create discord notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: discord
name: discord
type: discord
discord_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == False
- result.channel.name == "discord"
@@ -43,32 +43,32 @@
- name: Delete discord notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: discord
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == True
- name: Delete discord notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: discord
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/email.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/email.yml
index 85a236c9e..29e188755 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/email.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/email.yml
@@ -1,7 +1,7 @@
---
- name: Create email notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: email
name: email
type: email
@@ -10,21 +10,21 @@
- bar@example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "email"
- result.channel.type == "email"
- result.channel.uid == "email"
- name: Create email notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: email
name: email
type: email
@@ -33,47 +33,47 @@
- bar@example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "email"
- result.channel.type == "email"
- result.channel.uid == "email"
- name: Delete discord notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: email
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
- - "result.state == 'absent'"
+ - result.changed == True
+ - result.state == 'absent'
- name: Delete discord notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: email
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml
index abc7db644..8acdf0a68 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/googlechat.yml
@@ -1,74 +1,74 @@
---
- name: Create googlechat notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: googlechat
name: googlechat
type: googlechat
googlechat_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "googlechat"
- result.channel.uid == "googlechat"
- result.channel.type == "googlechat"
- name: Create googlechat notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: googlechat
name: googlechat
type: googlechat
googlechat_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "googlechat"
- result.channel.uid == "googlechat"
- result.channel.type == "googlechat"
- name: Delete googlechat notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: googlechat
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete googlechat notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: googlechat
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml
index 4a9ec1704..6423cafc8 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/hipchat.yml
@@ -1,74 +1,74 @@
---
- name: Create hipchat notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: hipchat
name: hipchat
type: hipchat
hipchat_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "hipchat"
- result.channel.type == "hipchat"
- result.channel.uid == "hipchat"
- name: Create hipchat notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: hipchat
name: hipchat
type: hipchat
hipchat_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "hipchat"
- result.channel.type == "hipchat"
- result.channel.uid == "hipchat"
- name: Delete hipchat notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: hipchat
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete hipchat notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: hipchat
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml
index ffc208acb..d8ec9cad3 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/kafka.yml
@@ -1,7 +1,7 @@
---
- name: Create kafka notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: kafka
name: kafka
type: kafka
@@ -9,21 +9,21 @@
kafka_topic: test
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "kafka"
- result.channel.uid == "kafka"
- result.channel.type == "kafka"
- name: Create kafka notification channel (idempotentcy)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: kafka
name: kafka
type: kafka
@@ -31,46 +31,46 @@
kafka_topic: test
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "kafka"
- result.channel.uid == "kafka"
- result.channel.type == "kafka"
- name: Delete kafka notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: kafka
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete kafka notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: kafka
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/line.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/line.yml
index 83a1863ba..dde928c3e 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/line.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/line.yml
@@ -1,74 +1,74 @@
---
- name: Create line notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: line
name: line
type: line
line_token: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.uid == "line"
- result.channel.name == "line"
- result.channel.type == "line"
- name: Create line notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: line
name: line
type: line
line_token: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.uid == "line"
- result.channel.name == "line"
- result.channel.type == "line"
- name: Delete line notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: line
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete line notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: line
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/main.yml
index ada6338c7..af0b2f861 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/main.yml
@@ -1,20 +1,34 @@
---
- block:
- - include: dingding.yml
- - include: discord.yml
- - include: email.yml
- - include: googlechat.yml
- - include: hipchat.yml
- - include: kafka.yml
-# - include: line.yml
- - include: teams.yml
- - include: opsgenie.yml
- - include: pagerduty.yml
- - include: prometheus.yml
- - include: pushover.yml
- - include: sensu.yml
- - include: slack-and-beyond.yml
- - include: telegram.yml
-# - include: threema.yml
- - include: victorops.yml
- - include: webhook.yml
+ - ansible.builtin.include_tasks:
+ file: dingding.yml
+ - ansible.builtin.include_tasks:
+ file: discord.yml
+ - ansible.builtin.include_tasks:
+ file: email.yml
+ - ansible.builtin.include_tasks:
+ file: googlechat.yml
+ - ansible.builtin.include_tasks:
+ file: hipchat.yml
+ - ansible.builtin.include_tasks:
+ file: kafka.yml
+ - ansible.builtin.include_tasks:
+ file: teams.yml
+ - ansible.builtin.include_tasks:
+ file: opsgenie.yml
+ - ansible.builtin.include_tasks:
+ file: pagerduty.yml
+ - ansible.builtin.include_tasks:
+ file: prometheus.yml
+ - ansible.builtin.include_tasks:
+ file: pushover.yml
+ - ansible.builtin.include_tasks:
+ file: sensu.yml
+ - ansible.builtin.include_tasks:
+ file: slack-and-beyond.yml
+ - ansible.builtin.include_tasks:
+ file: telegram.yml
+ - ansible.builtin.include_tasks:
+ file: victorops.yml
+ - ansible.builtin.include_tasks:
+ file: webhook.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml
index f871fe719..cd1048b86 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/opsgenie.yml
@@ -1,7 +1,7 @@
---
- name: Create opsgenie notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: opsgenie
name: opsgenie
type: opsgenie
@@ -9,21 +9,21 @@
opsgenie_api_key: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "opsgenie"
- result.channel.type == "opsgenie"
- result.channel.uid == "opsgenie"
- name: Create opsgenie notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: opsgenie
name: opsgenie
type: opsgenie
@@ -31,47 +31,47 @@
opsgenie_api_key: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "opsgenie"
- result.channel.type == "opsgenie"
- result.channel.uid == "opsgenie"
- name: Delete opsgenie notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: opsgenie
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
- - "result.state == 'absent'"
+ - result.changed == True
+ - result.state == 'absent'
- name: Delete opsgenie notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: opsgenie
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml
index a8fa940b0..40fd00468 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pagerduty.yml
@@ -1,74 +1,74 @@
---
- name: Create pagerduty notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pagerduty
name: pagerduty
type: pagerduty
pagerduty_integration_key: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "pagerduty"
- result.channel.type == "pagerduty"
- result.channel.uid == "pagerduty"
- name: Create pagerduty notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pagerduty
name: pagerduty
type: pagerduty
pagerduty_integration_key: xxx
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "pagerduty"
- result.channel.type == "pagerduty"
- result.channel.uid == "pagerduty"
- name: Delete pagerduty notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pagerduty
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete pagerduty notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pagerduty
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml
index 40810eaf3..c85d26f2e 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/prometheus.yml
@@ -1,74 +1,74 @@
---
- name: Create prometheus notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: prometheus
name: prometheus
type: prometheus
prometheus_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "prometheus"
- result.channel.uid == "prometheus"
- result.channel.type == "prometheus-alertmanager"
- name: Create prometheus notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: prometheus
name: prometheus
type: prometheus
prometheus_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "prometheus"
- result.channel.uid == "prometheus"
- result.channel.type == "prometheus-alertmanager"
- name: Delete prometheus notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: prometheus
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete prometheus notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: prometheus
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml
index 894bd71e6..ee7b9bea4 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/pushover.yml
@@ -1,7 +1,7 @@
---
- name: Create pushover notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pushover
name: pushover
type: pushover
@@ -9,21 +9,21 @@
pushover_user_key: yyy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "pushover"
- result.channel.uid == "pushover"
- result.channel.type == "pushover"
- name: Create pushover notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pushover
name: pushover
type: pushover
@@ -31,46 +31,46 @@
pushover_user_key: yyy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "pushover"
- result.channel.uid == "pushover"
- result.channel.type == "pushover"
- name: Delete pushover notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pushover
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete pushover notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: pushover
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml
index 01619b719..a46ef1d0a 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/sensu.yml
@@ -1,74 +1,74 @@
---
- name: Create sensu notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: sensu
name: sensu
type: sensu
sensu_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "sensu"
- result.channel.type == "sensu"
- result.channel.uid == "sensu"
- name: Create sensu notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: sensu
name: sensu
type: sensu
sensu_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "sensu"
- result.channel.type == "sensu"
- result.channel.uid == "sensu"
- name: Delete sensu notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: sensu
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete sensu notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: sensu
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml
index 0748c8bdb..1cbab6d5c 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/slack-and-beyond.yml
@@ -1,110 +1,110 @@
---
- name: Create slack notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: slack
name: slack
type: slack
slack_url: https://hooks.slack.com/services/xxx/yyy/zzz
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "slack"
- result.channel.type == "slack"
- result.channel.uid == "slack"
- name: Create slack notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: slack
name: slack
type: slack
slack_url: https://hooks.slack.com/services/xxx/yyy/zzz
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "slack"
- result.channel.type == "slack"
- result.channel.uid == "slack"
- name: Check slack notification channel idempotency
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: slack
name: slack
type: slack
slack_url: https://hooks.slack.com/services/xxx/yyy/zzz
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- name: Update slack notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: slack
name: slack
type: slack
slack_url: https://hooks.slack.com/services/xxx/yyy/fff
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete slack notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
state: absent
uid: slack
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete slack notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
state: absent
uid: slack
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/teams.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/teams.yml
index cfc44aef3..d9c7471c5 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/teams.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/teams.yml
@@ -1,74 +1,74 @@
---
- name: Create teams notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: teams
name: teams
type: teams
teams_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "teams"
- result.channel.uid == "teams"
- result.channel.type == "teams"
- name: Create teams notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: teams
name: teams
type: teams
teams_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "teams"
- result.channel.uid == "teams"
- result.channel.type == "teams"
- name: Delete teams notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: teams
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete teams notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: teams
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml
index 98a7a3c6d..38e27ef57 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/telegram.yml
@@ -1,7 +1,7 @@
---
- name: Create telegram notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: telegram
name: telegram
type: telegram
@@ -9,21 +9,21 @@
telegram_chat_id: yyy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "telegram"
- result.channel.type == "telegram"
- result.channel.uid == "telegram"
- name: Create telegram notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: telegram
name: telegram
type: telegram
@@ -31,46 +31,46 @@
telegram_chat_id: yyy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "telegram"
- result.channel.type == "telegram"
- result.channel.uid == "telegram"
- name: Delete telegram notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: telegram
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete telegram notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: telegram
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/threema.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/threema.yml
index 7858b6977..c61eae316 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/threema.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/threema.yml
@@ -1,7 +1,7 @@
---
- name: Create threema notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: threema
name: threema
type: threema
@@ -10,21 +10,21 @@
threema_api_secret: zzz
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "threema"
- result.channel.type == "threema"
- result.channel.uid == "threema"
- name: Create threema notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: threema
name: threema
type: threema
@@ -33,46 +33,46 @@
threema_api_secret: zzz
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "threema"
- result.channel.type == "threema"
- result.channel.uid == "threema"
- name: Delete threema notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: threema
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete threema notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: threema
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml
index 3779e813a..e21679132 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/victorops.yml
@@ -1,74 +1,74 @@
---
- name: Create victorops notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: victorops
name: victorops
type: victorops
victorops_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "victorops"
- result.channel.type == "victorops"
- result.channel.uid == "victorops"
- name: Create victorops notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: victorops
name: victorops
type: victorops
victorops_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "victorops"
- result.channel.type == "victorops"
- result.channel.uid == "victorops"
- name: Delete victorops notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: victorops
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete victorops notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: victorops
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml
index c9efd9193..5a00878f9 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_notification_channel/tasks/webhook.yml
@@ -1,74 +1,74 @@
---
- name: Create webhook notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: webhook
name: webhook
type: webhook
webhook_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- result.channel.name == "webhook"
- result.channel.uid == "webhook"
- result.channel.type == "webhook"
- name: Create webhook notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: webhook
name: webhook
type: webhook
webhook_url: https://example.org
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
- result.channel.name == "webhook"
- result.channel.uid == "webhook"
- result.channel.type == "webhook"
- name: Delete webhook notification channel
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: webhook
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == True"
+ - result.changed == True
- name: Delete webhook notification channel (idempotency)
register: result
- grafana_notification_channel:
+ community.grafana.grafana_notification_channel:
uid: webhook
state: absent
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password}}"
+ grafana_password: "{{ grafana_password }}"
-- debug:
+- ansible.builtin.debug:
var: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == False"
+ - result.changed == False
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/defaults/main.yml
index 7bb77ea3f..3edac8598 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/defaults/main.yml
@@ -1,4 +1,4 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/runme.sh
new file mode 100755
index 000000000..9daa487db
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml --check
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/site.yml
new file mode 100644
index 000000000..e2e4900bd
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_organization
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_organization
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/tasks/main.yml
index f8ccdf3bf..936b147cb 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization/tasks/main.yml
@@ -1,5 +1,4 @@
---
-
- name: Create a Grafana organization
community.grafana.grafana_organization:
url: "{{ grafana_url }}"
@@ -8,13 +7,15 @@
name: orgtest
state: present
register: result
-- assert:
+
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.failed == false"
- - "result.org.name == 'orgtest'"
+ - result.changed == true
+ - result.failed == false
+ - result.org.name == 'orgtest'
+ when: not ansible_check_mode
-- name: check idempotency Grafana organization
+- name: Check idempotency Grafana organization
community.grafana.grafana_organization:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
@@ -22,11 +23,13 @@
name: orgtest
state: present
register: result
-- assert:
+
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.failed == false"
- - "result.org.name == 'orgtest'"
+ - result.changed == false
+ - result.failed == false
+ - result.org.name == 'orgtest'
+ when: not ansible_check_mode
- name: Delete a Grafana organization
community.grafana.grafana_organization:
@@ -36,13 +39,15 @@
name: orgtest
state: absent
register: result
-- assert:
+
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.failed == false"
- - "result.msg |length > 0"
+ - result.changed == true
+ - result.failed == false
+ - result.msg |length > 0
+ when: not ansible_check_mode
-- name: check idempotency delete a Grafana organization
+- name: Check idempotency delete a Grafana organization
community.grafana.grafana_organization:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
@@ -50,8 +55,10 @@
name: orgtest
state: absent
register: result
-- assert:
+
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.failed == false"
- - "result.msg == 'No org found, nothing to do'"
+ - result.changed == false
+ - result.failed == false
+ - result.msg == 'No org found, nothing to do'
+ when: not ansible_check_mode
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/defaults/main.yml
new file mode 100644
index 000000000..3edac8598
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/runme.sh
new file mode 100755
index 000000000..9daa487db
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml --check
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/site.yml
new file mode 100644
index 000000000..80e5ea916
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_organization_user
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_organization_user
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/tasks/main.yml
new file mode 100644
index 000000000..73b0482ac
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_organization_user/tasks/main.yml
@@ -0,0 +1,172 @@
+---
+- name: Create test user (default org 1)
+ community.grafana.grafana_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: orgtest
+ email: orgtest@example.com
+ login: orgtest
+ password: userpassword
+ state: present
+ register: result
+
+- name: Remove user from organization (default org 1)
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ login: orgtest
+ state: absent
+ register: result
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ when: not ansible_check_mode
+
+- name: Check idempotency on user removal from org
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ login: orgtest
+ state: absent
+ register: result
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == false
+ when: not ansible_check_mode
+
+- name: Add user to organization
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ login: orgtest
+ role: viewer
+ state: present
+ register: result
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ - result.user.orgId == 1
+ - result.user.role == 'Viewer'
+ when: not ansible_check_mode
+
+- name: Update existing user role
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ login: orgtest
+ role: editor
+ state: present
+ register: result
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ - result.user.orgId == 1
+ - result.user.role == 'Editor'
+ when: not ansible_check_mode
+
+- name: Check idempotency on user update
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ login: orgtest
+ role: editor
+ state: present
+ register: result
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == false
+ when: not ansible_check_mode
+
+- name: Create a new organization
+ community.grafana.grafana_organization:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: neworgtest
+ state: present
+ register: org
+
+- name: Add user to the new organization by org_id
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ org_id: "{{ org.org.id }}"
+ login: orgtest
+ role: admin
+ state: present
+ register: result
+ when: not ansible_check_mode
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ - result.user.orgId == org.org.id
+ - result.user.role == 'Admin'
+ when: not ansible_check_mode
+
+- name: Remove user from new organization by org_id
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ org_id: "{{ org.org.id }}"
+ login: orgtest
+ state: absent
+ register: result
+ when: not ansible_check_mode
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ when: not ansible_check_mode
+
+- name: Add user to the new organization by org_name
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ org_name: "{{ org.org.name }}"
+ login: orgtest
+ role: admin
+ state: present
+ register: result
+ when: not ansible_check_mode
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ - result.user.orgId == org.org.id
+ - result.user.role == 'Admin'
+ when: not ansible_check_mode
+
+- name: Remove user from new organization by org_name
+ community.grafana.grafana_organization_user:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ org_name: "{{ org.org.name }}"
+ login: orgtest
+ state: absent
+ register: result
+ when: not ansible_check_mode
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == false
+ - result.changed == true
+ when: not ansible_check_mode
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/defaults/main.yml
index 8b9c9348a..4abf9bb43 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/defaults/main.yml
@@ -1,7 +1,5 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
-
-...
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/runme.sh
new file mode 100755
index 000000000..867afb0d3
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/site.yml
new file mode 100644
index 000000000..c8a618891
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_team
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_team
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/create_user.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/create_user.yml
index 6971d07b6..9641e7185 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/create_user.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/create_user.yml
@@ -1,29 +1,30 @@
+---
- name: Create John Doe for tests purpose through uri module
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/admin/users"
method: POST
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
body:
- name: "John"
- email: "john+doe@example.com"
- login: "john"
- password: "userpassword"
+ name: John
+ email: john+doe@example.com
+ login: john
+ password: userpassword
body_format: json
status_code: 200
- name: Create Jane Doe for tests purpose through uri module
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/admin/users"
method: POST
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
body:
- name: "Jane"
- email: "jane.doe@example.com"
- login: "jane"
- password: "userpassword"
+ name: Jane
+ email: jane.doe@example.com
+ login: jane
+ password: userpassword
body_format: json
status_code: 200
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/main.yml
index 2d74581b7..d43eb8286 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_team/tasks/main.yml
@@ -1,187 +1,198 @@
---
-
- name: Create a Team
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ state: present
+ skip_version_check: true
register: result
-- set_fact:
+- ansible.builtin.set_fact:
# From Grafana 9.0.0, the API user automatically becomes a member of the team
auto_member: "{{ result.team.memberCount == 1 }}"
-- set_fact:
+- ansible.builtin.set_fact:
expected_members: "{{ auto_member | ternary(['********@localhost'], []) }}"
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == true
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
- name: Check idempotency on team creation
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == false
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
- name: Check a team can be deleted
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- state: absent
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ state: absent
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.message == 'Team deleted'"
+ - result.changed == true
+ - result.message == 'Team deleted'
+ when: not ansible_check_mode
- name: Check idempotency on team deletion
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- state: absent
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ state: absent
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.message == 'No team found'"
+ - result.changed == false
+ - result.message == 'No team found'
+ when: not ansible_check_mode
- name: Create users for tests purpose
- import_tasks: create_user.yml
+ ansible.builtin.import_tasks:
+ file: create_user.yml
- name: Create a Team with members
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- members:
- - "john+doe@example.com"
- - "jane.doe@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ members:
+ - john+doe@example.com
+ - jane.doe@example.com
+ state: present
register: result
-- set_fact:
- expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com']) }}"
+- ansible.builtin.set_fact:
+ expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com'])
+ }}"
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == true
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
- name: Ensure a Team exists with member not enforced
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- members:
- - "john+doe@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ members:
+ - john+doe@example.com
+ state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
-
-- set_fact:
+ - result.changed == false
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
+
+- ansible.builtin.set_fact:
enforced_members: "{{ auto_member | ternary(['admin@localhost', 'john+doe@example.com'], ['john+doe@example.com']) }}"
expected_members: "{{ auto_member | ternary(['********@localhost', 'john+doe@example.com'], ['john+doe@example.com']) }}"
- name: Ensure a Team exists with member enforced
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- members: "{{ enforced_members }}"
- enforce_members: true
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ members: "{{ enforced_members }}"
+ enforce_members: true
+ state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == true
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
- name: Ensure a Team exists with members omitted
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == false
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
- name: Add new member to existing Team
- grafana_team:
- url: "{{ grafana_url }}"
- url_username: "{{ grafana_username }}"
- url_password: "{{ grafana_password }}"
- name: "grafana_working_group"
- email: "foo.bar@example.com"
- members:
- - "john+doe@example.com"
- - "jane.doe@example.com"
- state: present
+ community.grafana.grafana_team:
+ url: "{{ grafana_url }}"
+ url_username: "{{ grafana_username }}"
+ url_password: "{{ grafana_password }}"
+ name: grafana working group
+ email: foo.bar@example.com
+ members:
+ - john+doe@example.com
+ - jane.doe@example.com
+ state: present
register: result
-- set_fact:
- expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com']) }}"
+- ansible.builtin.set_fact:
+ expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com'])
+ }}"
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.team.name == 'grafana_working_group'"
- - "result.team.email == 'foo.bar@example.com'"
- - "result.team.memberCount == (expected_members|length)"
- - "result.team.members == expected_members"
+ - result.changed == true
+ - result.team.name == 'grafana working group'
+ - result.team.email == 'foo.bar@example.com'
+ - result.team.memberCount == (expected_members|length)
+ - result.team.members == expected_members
+ when: not ansible_check_mode
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/defaults/main.yml
index 7bb77ea3f..3edac8598 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/defaults/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/defaults/main.yml
@@ -1,4 +1,4 @@
---
-grafana_url: "http://grafana:3000/"
-grafana_username: "admin"
-grafana_password: "admin"
+grafana_url: http://grafana:3000/
+grafana_username: admin
+grafana_password: admin
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/runme.sh
new file mode 100755
index 000000000..9daa487db
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/runme.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ansible-playbook site.yml --check
+ansible-playbook site.yml
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/site.yml
new file mode 100644
index 000000000..b080803f8
--- /dev/null
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/site.yml
@@ -0,0 +1,6 @@
+---
+- name: Run tests for grafana_user
+ hosts: localhost
+ tasks:
+ - ansible.builtin.include_role:
+ name: ../../grafana_user
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/tasks/main.yml
index c62801653..83a3891e1 100644
--- a/ansible_collections/community/grafana/tests/integration/targets/grafana_user/tasks/main.yml
+++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_user/tasks/main.yml
@@ -1,237 +1,251 @@
---
- name: Create new admin
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Harley Quinn"
+ name: Harley Quinn
email: harley.quinn@gotham.city
login: harley
password: Wy3ta6ob6M3wHELv58MPfqOe126RTnWpcYfEhyJm
is_admin: true
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.failed == false"
- - "result.user.name == 'Harley Quinn'"
- - "result.user.email == 'harley.quinn@gotham.city'"
- - "result.user.isGrafanaAdmin == true"
+ - result.changed == true
+ - result.failed == false
+ - result.user.name == 'Harley Quinn'
+ - result.user.email == 'harley.quinn@gotham.city'
+ - result.user.isGrafanaAdmin == true
+ when: not ansible_check_mode
- name: Check idempotency on admin creation
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Harley Quinn"
+ name: Harley Quinn
email: harley.quinn@gotham.city
login: harley
password: Wy3ta6ob6M3wHELv58MPfqOe126RTnWpcYfEhyJm
is_admin: true
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.user.name == 'Harley Quinn'"
- - "result.user.email == 'harley.quinn@gotham.city'"
- - "result.user.isGrafanaAdmin == true"
+ - result.changed == false
+ - result.user.name == 'Harley Quinn'
+ - result.user.email == 'harley.quinn@gotham.city'
+ - result.user.isGrafanaAdmin == true
+ when: not ansible_check_mode
- name: Check user creation with Grafana API
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/users/lookup?loginOrEmail=harley"
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
status_code: 200
headers:
Accept: application/json
Content-Type: application/json
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.json.name == 'Harley Quinn'"
- - "result.json.email == 'harley.quinn@gotham.city'"
- - "result.json.isGrafanaAdmin == true"
+ - result.json.name == 'Harley Quinn'
+ - result.json.email == 'harley.quinn@gotham.city'
+ - result.json.isGrafanaAdmin == true
+ when: not ansible_check_mode
- name: Create a Grafana user without password (expect failure)
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Bruce Wayne"
+ name: Bruce Wayne
email: batman@gotham.city
login: batman
state: present
register: result
- ignore_errors: yes
-- assert:
+ ignore_errors: true
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.failed == true"
+ - result.changed == false
+ - result.failed == true
- "result.msg == 'missing required arguments: password'"
+ when: not ansible_check_mode
- name: Create a Grafana user
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Bruce Wayne"
+ name: Bruce Wayne
email: batman@gotham.city
login: batman
password: robin
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.user.name == 'Bruce Wayne'"
- - "result.user.email == 'batman@gotham.city'"
- - "result.user.isGrafanaAdmin == false"
+ - result.changed == true
+ - result.user.name == 'Bruce Wayne'
+ - result.user.email == 'batman@gotham.city'
+ - result.user.isGrafanaAdmin == false
+ when: not ansible_check_mode
- name: Check idempotency on user creation (password not requiered)
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Bruce Wayne"
+ name: Bruce Wayne
email: batman@gotham.city
login: batman
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.user.name == 'Bruce Wayne'"
- - "result.user.email == 'batman@gotham.city'"
- - "result.user.isGrafanaAdmin == false"
+ - result.changed == false
+ - result.user.name == 'Bruce Wayne'
+ - result.user.email == 'batman@gotham.city'
+ - result.user.isGrafanaAdmin == false
+ when: not ansible_check_mode
- name: Check user creation with Grafana API
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman"
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
status_code: 200
headers:
Accept: application/json
Content-Type: application/json
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.json.name == 'Bruce Wayne'"
- - "result.json.email == 'batman@gotham.city'"
- - "result.json.isGrafanaAdmin == false"
+ - result.json.name == 'Bruce Wayne'
+ - result.json.email == 'batman@gotham.city'
+ - result.json.isGrafanaAdmin == false
+ when: not ansible_check_mode
- name: Update Grafana user
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "The Dark Knight"
+ name: The Dark Knight
email: thedarkknight@gotham.city
login: batman
password: robin
is_admin: true
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.user.name == 'The Dark Knight'"
- - "result.user.email == 'thedarkknight@gotham.city'"
- - "result.user.isGrafanaAdmin == true"
+ - result.changed == true
+ - result.user.name == 'The Dark Knight'
+ - result.user.email == 'thedarkknight@gotham.city'
+ - result.user.isGrafanaAdmin == true
+ when: not ansible_check_mode
- name: Check user update with Grafana API
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman"
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
status_code: 200
headers:
Accept: application/json
Content-Type: application/json
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.json.name == 'The Dark Knight'"
- - "result.json.email == 'thedarkknight@gotham.city'"
- - "result.json.isGrafanaAdmin == true"
+ - result.json.name == 'The Dark Knight'
+ - result.json.email == 'thedarkknight@gotham.city'
+ - result.json.isGrafanaAdmin == true
+ when: not ansible_check_mode
- name: Delete a Grafana user
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
login: batman
state: absent
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.message == 'User deleted'"
+ - result.changed == true
+ - result.message == 'User deleted'
+ when: not ansible_check_mode
- name: Check idempotency on user deletion
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
login: batman
state: absent
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.message == 'No user found, nothing to do'"
+ - result.changed == false
+ - result.message == 'No user found, nothing to do'
+ when: not ansible_check_mode
- name: Check user deletion with Grafana API (expect 404 Not Found)
- uri:
+ ansible.builtin.uri:
url: "{{ grafana_url }}api/users/lookup?loginOrEmail=batman"
user: "{{ grafana_username }}"
password: "{{ grafana_password }}"
- force_basic_auth: yes
+ force_basic_auth: true
status_code: 404
headers:
Accept: application/json
Content-Type: application/json
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.json.message | lower == 'user not found'"
+ - result.json.message | lower == 'user not found'
+ when: not ansible_check_mode
- name: Create a Grafana user with character encoding
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Bruce Wayne"
+ name: Bruce Wayne
email: bruce+wayne@gotham.city
login: bruce+wayne@gotham.city
password: robin
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == true"
- - "result.user.name == 'Bruce Wayne'"
- - "result.user.email == 'bruce+wayne@gotham.city'"
- - "result.user.isGrafanaAdmin == false"
+ - result.changed == true
+ - result.user.name == 'Bruce Wayne'
+ - result.user.email == 'bruce+wayne@gotham.city'
+ - result.user.isGrafanaAdmin == false
+ when: not ansible_check_mode
- name: Check idempotency on user creation (password not requiered)
- grafana_user:
+ community.grafana.grafana_user:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
- name: "Bruce Wayne"
+ name: Bruce Wayne
email: bruce+wayne@gotham.city
login: bruce+wayne@gotham.city
state: present
register: result
-- assert:
+- ansible.builtin.assert:
that:
- - "result.changed == false"
- - "result.user.name == 'Bruce Wayne'"
- - "result.user.email == 'bruce+wayne@gotham.city'"
- - "result.user.isGrafanaAdmin == false"
+ - result.changed == false
+ - result.user.name == 'Bruce Wayne'
+ - result.user.email == 'bruce+wayne@gotham.city'
+ - result.user.isGrafanaAdmin == false
+ when: not ansible_check_mode