X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Finfra-ansible.git;a=blobdiff_plain;f=roles%2Fcleanup_disks%2Ftasks%2Fdestroy_data_and_partitions.yml;h=7e859042e0c0c0a791f449dc1432ea5a1ef1c907;hp=48aeff528b48cc8c10dd008b80ab877eb73ca332;hb=b2e13865c2b899ce48148879da20323bd9bc988c;hpb=3a7fca60d2a33657024ad83011ee233c879b416a diff --git a/roles/cleanup_disks/tasks/destroy_data_and_partitions.yml b/roles/cleanup_disks/tasks/destroy_data_and_partitions.yml index 48aeff5..7e85904 100644 --- a/roles/cleanup_disks/tasks/destroy_data_and_partitions.yml +++ b/roles/cleanup_disks/tasks/destroy_data_and_partitions.yml @@ -14,20 +14,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: check whether disks exist and are block devices + stat: path={{ item }} + with_items: "{{ disks }}" + register: disks_stat + - name: wipe off filesystems from disks - shell: "[ -b {{ item }} ] | /usr/sbin/wipefs --all --force {{ item }} || /usr/sbin/wipefs --all --force {{ item }}" + command: "/usr/sbin/wipefs --all --force {{ item.item }}" args: creates: "{{ creates_file }}" - with_items: "{{ disks }}" + with_items: "{{ disks_stat.results }}" + when: item.stat.exists and item.stat.isblk - name: destroy data from disks - shell: "[ -b {{ item }} ] | dd if=/dev/zero of={{ item }} count=200 bs=1M" + command: "dd if=/dev/zero of={{ item.item }} count=200 bs=1M" args: creates: "{{ creates_file }}" - with_items: "{{ disks }}" + with_items: "{{ disks_stat.results }}" + when: item.stat.exists and item.stat.isblk - name: destroy partitions from disks - shell: "[ -b {{ item }} ] | /usr/sbin/sgdisk --zap-all --clear --mbrtogpt -- {{ item }} || /usr/sbin/sgdisk --zap-all --clear --mbrtogpt -- {{ item }}" + command: "/usr/sbin/sgdisk --zap-all --clear --mbrtogpt -- {{ item.item }}" args: creates: "{{ creates_file }}" - with_items: "{{ disks }}" + with_items: "{{ disks_stat.results }}" + when: item.stat.exists and item.stat.isblk