grafana-ansible-collection/tests/integration/targets/cloud_api_key/tasks/main.yml

48 lines
1.3 KiB
YAML
Raw Normal View History

2023-03-03 09:53:02 +01: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 }}"
2023-03-03 09:53:02 +01:00
fail_if_already_created: false
state: present
register: add_result
2023-03-03 09:53:02 +01:00
- name: Add Check
ansible.builtin.assert:
that:
2022-10-10 07:25:55 +02:00
- add_result.output.name == "ansible-integration-test"
2023-03-03 09:53:02 +01:00
when: add_result.output.name is defined
- 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 }}"
2023-03-03 09:53:02 +01:00
fail_if_already_created: false
state: present
register: update_result
2023-03-03 09:53:02 +01:00
- name: Update Check
ansible.builtin.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
2023-03-03 09:53:02 +01:00
- name: Delete Check
ansible.builtin.assert:
that:
- delete_result.changed == true
- delete_result.output == "Cloud API key is deleted"