-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreset-gluster-demo.yml
82 lines (67 loc) · 2.6 KB
/
reset-gluster-demo.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#IN CASE OF EMERGENCY:
# ansible gluster1 -m mount -a 'path=/gluster/vol1 state=absent'
# gluster vol stop vol1 --mode=script ; gluster vol delete vol1 --mode=script
# for i in {1..6}; do ssh gluster$i "rm -rf /bricks/sda/vol1"; ssh gluster$i "mkdir /bricks/sda/vol1"; done
# for i in {1..6}; do ssh gluster$i "rm -rf /bricks/sdb/vol1"; ssh gluster$i "mkdir /bricks/sdb/vol1"; done
# ansible all -m mount -a 'path=/bricks/sda state=absent'
# ansible all -m mount -a 'path=/bricks/sdb state=absent'
# for i in {2..6}; do gluster peer detach gluster$i; done
# ansible all -a "wipefs -af /dev/sda"
# ansible all -a "wipefs -af /dev/sdb"
---
- hosts: all
gather_facts: no
ignore_errors: yes
tasks:
- name: "Unmount the client's volume"
mount: path=/gluster/{{ item }} state=absent
with_items: [ vol1, vol1-snaps, vol1-clone ]
- name: "Stop the Gluster volume"
gluster_volume: name=vol1-clone state=stopped
run_once: yes
# - name: "Deactivate the Gluster volume's snapshots"
# command: gluster snapshot deactivate snap1 --mode=script
# run_once: yes
- name: "Delete the Gluster volume's snapshots"
command: gluster snapshot delete all --mode=script
run_once: yes
- name: "Delete the Gluster volume clone"
gluster_volume: name=vol1-clone state=absent
run_once: yes
- name: "Delete the Gluster volume"
gluster_volume: name=vol1 state=absent
run_once: yes
- copy:
content: |
#!/bin/bash
for i in $(lvs --no-heading -o vg_name,lv_name | awk '{print "/dev/" $1 "/" $2}'); do umount -v $i; done
dest: /tmp/umount_all.sh
mode: 0755
- name: "Force unmount /run/gluster/snaps/* dirs"
script: /tmp/umount_all.sh
- name: "unset gluster snapshot options"
command: gluster snapshot config auto-delete disable --mode=script
run_once: yes
- command: gluster snapshot config activate-on-create disable --mode=script
run_once: yes
- name: "Dissolve the Trusted Storage Pool"
command: gluster peer detach {{ item }}
with_items: [ gluster2, gluster3 ]
delegate_to: gluster1
- name: "Cleanup the nodes' fstab"
mount:
path: /rhgs/{{ item }}
state: absent
with_items: [ sdb, sdc, sdd ]
- name: "Remove the LVs"
command: lvremove vg_{{ item }} --force
with_items: [ sdb, sdc, sdd ]
- name: "Remove the VGs"
command: vgremove vg_{{ item }} --force
with_items: [ sdb, sdc, sdd ]
- name: "Remove the PVs"
command: pvremove /dev/{{ item }} --force
with_items: [ sdb, sdc, sdd ]
# - name: "Wipe the drives"
# command: wipefs -af /dev/{{ item }}
# with_items: [ sda, sdb, sdc ]