2 - name: remove golang tarball
\r
4 path: "/opt/{{ golang_tarball }}"
\r
9 - name: kill etcd daemon service
\r
12 when: db_driver == "etcd"
\r
14 - name: remove etcd service data
\r
16 path: "{{ etcd_dir }}"
\r
20 when: db_driver == "etcd"
\r
22 - name: remove etcd tarball
\r
24 path: "/opt/{{ etcd_tarball }}"
\r
28 when: db_driver == "etcd"
\r
30 - name: kill osdslet daemon service
\r
31 shell: killall osdslet
\r
34 - name: kill osdsdock daemon service
\r
35 shell: killall osdsdock
\r
38 - name: clean all opensds build files
\r
39 shell: . /etc/profile; make clean
\r
41 chdir: "{{ opensds_root_dir }}"
\r
43 - name: clean all opensds configuration files
\r
45 path: "{{ opensds_config_dir }}"
\r
50 - name: clean all opensds log files
\r
52 path: "{{ opensds_log_dir }}"
\r
57 - name: check if it existed before cleaning a volume group
\r
58 shell: vgdisplay {{ vg_name }}
\r
60 register: vg_existed
\r
61 when: enabled_backend == "lvm"
\r
63 - name: remove a volume group if lvm backend specified
\r
64 shell: vgremove {{ vg_name }}
\r
65 when: enabled_backend == "lvm" and vg_existed.rc == 0
\r
67 - name: check if it existed before cleaning a physical volume
\r
68 shell: pvdisplay {{ pv_device }}
\r
70 register: pv_existed
\r
71 when: enabled_backend == "lvm"
\r
73 - name: remove a physical volume if lvm backend specified
\r
74 shell: pvremove {{ pv_device }}
\r
75 when: enabled_backend == "lvm" and pv_existed.rc == 0
\r
77 - name: stop cinder-standalone service
\r
78 shell: docker-compose down
\r
81 chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
\r
82 when: enabled_backend == "cinder"
\r
84 - name: clean the volume group of cinder
\r
88 # _clean_lvm_volume_group removes all default LVM volumes
\r
90 # Usage: _clean_lvm_volume_group $vg
\r
91 function _clean_lvm_volume_group {
\r
94 # Clean out existing volumes
\r
95 sudo lvremove -f $vg
\r
98 # _remove_lvm_volume_group removes the volume group
\r
100 # Usage: _remove_lvm_volume_group $vg
\r
101 function _remove_lvm_volume_group {
\r
104 # Remove the volume group
\r
105 sudo vgremove -f $vg
\r
108 # _clean_lvm_backing_file() removes the backing file of the
\r
111 # Usage: _clean_lvm_backing_file() $backing_file
\r
112 function _clean_lvm_backing_file {
\r
113 local backing_file=$1
\r
115 # If the backing physical device is a loop device, it was probably setup by DevStack
\r
116 if [[ -n "$backing_file" ]] && [[ -e "$backing_file" ]]; then
\r
118 vg_dev=$(sudo losetup -j $backing_file | awk -F':' '/'.img'/ { print $1}')
\r
119 if [[ -n "$vg_dev" ]]; then
\r
120 sudo losetup -d $vg_dev
\r
122 rm -f $backing_file
\r
126 # clean_lvm_volume_group() cleans up the volume group and removes the
\r
129 # Usage: clean_lvm_volume_group $vg
\r
130 function clean_lvm_volume_group {
\r
133 _clean_lvm_volume_group $vg
\r
134 _remove_lvm_volume_group $vg
\r
135 # if there is no logical volume left, it's safe to attempt a cleanup
\r
136 # of the backing file
\r
137 if [[ -z "$(sudo lvs --noheadings -o lv_name $vg 2>/dev/null)" ]]; then
\r
138 _clean_lvm_backing_file {{ cinder_data_dir }}/${vg}.img
\r
142 clean_lvm_volume_group {{cinder_volume_group}}
\r
145 executable: /bin/bash
\r
147 when: enabled_backend == "cinder"
\r