2022-08-23 15:42:32 +02:00
|
|
|
- name: Create Grafana Cloud API key
|
|
|
|
grafana.grafana.cloud_api_key:
|
|
|
|
name: ansible-integration-test
|
|
|
|
role: Admin
|
|
|
|
org_slug: "{{ org_name }}"
|
|
|
|
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
2022-10-10 08:12:54 +02:00
|
|
|
fail_if_already_created: False
|
2022-08-23 15:42:32 +02:00
|
|
|
state: present
|
|
|
|
register: add_result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2022-10-10 07:25:55 +02:00
|
|
|
- add_result.output.name == "ansible-integration-test"
|
2022-10-10 08:09:33 +02:00
|
|
|
when: add_result.output.name is defined
|
2022-08-23 15:42:32 +02:00
|
|
|
|
|
|
|
- name: Re-run previous task
|
|
|
|
grafana.grafana.cloud_api_key:
|
|
|
|
name: ansible-integration-test
|
|
|
|
role: Admin
|
|
|
|
org_slug: "{{ org_name }}"
|
|
|
|
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
|
|
|
fail_if_already_created: False
|
|
|
|
state: present
|
|
|
|
register: update_result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- update_result.changed == false
|
|
|
|
- update_result.output == "A Cloud API key with the same name already exists"
|
|
|
|
|
|
|
|
- name: Delete Grafana Cloud API key
|
|
|
|
grafana.grafana.cloud_api_key:
|
|
|
|
name: ansible-integration-test
|
|
|
|
role: Admin
|
|
|
|
org_slug: "{{ org_name }}"
|
|
|
|
existing_cloud_api_key: "{{ grafana_cloud_api_key }}"
|
|
|
|
state: absent
|
|
|
|
register: delete_result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- delete_result.changed == true
|
2022-10-07 08:19:18 +02:00
|
|
|
- delete_result.output == "Cloud API key is deleted"
|