ba187cde5def36f47f6504ee6917b944bd461be9
[ta/infra-ansible.git] / playbooks / destroy_data_and_partitions.yml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - name: check whether disks exist and are block devices
18   stat: path={{ item }}
19   with_items: "{{ disks }}"
20   register: disks_stat
21
22 - name: wipe off filesystems from disks
23   command: "/usr/sbin/wipefs --all --force {{ item.item }}"
24   args:
25     creates: /etc/storage/osd_disk_metadata.json
26   with_items: "{{ disks_stat.results }}"
27   when: item.stat.exists and item.stat.isblk
28
29 - name: destroy data from disks
30   command: "dd if=/dev/zero of={{ item.item }} count=200 bs=1M"
31   args:
32     creates: /etc/storage/osd_disk_metadata.json
33   with_items: "{{ disks_stat.results }}"
34   when: item.stat.exists and item.stat.isblk
35
36 - name: destroy partitions from disks
37   command: "/usr/sbin/sgdisk --zap-all --clear --mbrtogpt -- {{ item.item }}"
38   args:
39     creates: /etc/storage/osd_disk_metadata.json
40   with_items: "{{ disks_stat.results }}"
41   when: item.stat.exists and item.stat.isblk