-
Notifications
You must be signed in to change notification settings - Fork 12
/
purge-local.yml
45 lines (35 loc) · 1.18 KB
/
purge-local.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
37
38
39
40
41
42
43
---
- name: Confirm before deleting the Grafana/Prometheus environment
hosts: localhost
gather_facts: false
become: false
vars:
deploy_local: true
vars_prompt:
- name: confirm_delete
prompt: |
Are you sure you want to stop the containers and delete all the prometheus data?
default: 'no'
private: no
tasks:
- name: User cancelled purge process
ansible.builtin.meta: end_play
when: not ( confirm_delete | bool )
- name: Purge the environment
block:
- name: import common
ansible.builtin.include_role:
name: common
public: true
- name: Generate prom_dir path
set_fact:
prom_path: "{{ lookup('env', 'HOME') }}/{{ prom_dir }}"
- name: Delete containers (docker)
command: "{{ container_engine }}-compose down"
when: container_engine == "docker"
- name: Delete the containers (podman)
shell: podman pod stop perfscale && podman pod rm perfscale
when: container_engine == "podman"
- name: Remove data from {{ prom_path }}
shell: rm -rf {{ prom_path }}
when: confirm_delete | bool