forked from redhat-performance/odf-grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
purge-grafana.yml
38 lines (31 loc) · 1.12 KB
/
purge-grafana.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
- name: Purge standalone Grafana namespace
hosts: localhost
gather_facts: false
vars:
grafana_namespace: ''
tasks:
- name: Check namespace is set
fail:
msg: "You must set the grafana_namespace variable - Hint: -e grafana_namespace=perfscale"
when: grafana_namespace | length == 0
- name: Gather available namespaces
command:
cmd: oc get ns -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'
register: namespace_list
- name: Check namespace exists
fail:
msg: "{{ grafana_namespace }} does not exist. Aborting."
when: grafana_namespace not in namespace_list.stdout_lines
- name: Confirm before deletion
pause:
prompt: Are you sure you want to delete the namespace '{{ grafana_namespace }}' (yes/no) ?
register: confirm
- name: Aborting the namespace delete
debug:
msg: Aborted the namespace delete
when: confirm.user_input.upper() != 'YES'
- name: Deleting the namespace
command:
cmd: oc delete ns {{ grafana_namespace }}
when: confirm.user_input.upper() == 'YES'