2016-08-10 06:57:41 +08:00
|
|
|
---
|
|
|
|
- name: check if the device is a partition
|
2016-09-19 22:17:11 +08:00
|
|
|
shell: "readlink -f {{ item }} | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'"
|
2016-08-17 05:49:30 +08:00
|
|
|
with_items: "{{ devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-08-17 05:49:30 +08:00
|
|
|
register: ispartition_results
|
2016-08-10 06:57:41 +08:00
|
|
|
|
|
|
|
- name: check the partition status of the osd disks
|
|
|
|
shell: "parted --script {{ item }} print > /dev/null 2>&1"
|
2016-08-17 05:49:30 +08:00
|
|
|
with_items: "{{ devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-08-17 05:49:30 +08:00
|
|
|
register: osd_partition_status_results
|
2016-08-10 06:57:41 +08:00
|
|
|
|
|
|
|
# NOTE: The following calls to sgdisk are retried because sgdisk is known to
|
|
|
|
# fully wipe a device the first time around. There is no need to halt execution
|
|
|
|
# of zapping the whole device so these try again. It is easier to use `||` to
|
|
|
|
# keep the current flow of the task.
|
|
|
|
# See: https://github.com/ceph/ceph-ansible/issues/759
|
|
|
|
- name: fix partitions gpt header or labels of the osd disks
|
|
|
|
shell: "sgdisk --zap-all --clear --mbrtogpt -- {{ item.1 }} || sgdisk --zap-all --clear --mbrtogpt -- {{ item.1 }}"
|
|
|
|
with_together:
|
2016-08-17 05:49:30 +08:00
|
|
|
- "{{ osd_partition_status_results.results }}"
|
|
|
|
- "{{ devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
2016-11-03 22:20:07 +08:00
|
|
|
when: item.0.rc != 0
|
2016-08-10 06:57:41 +08:00
|
|
|
|
|
|
|
- name: check if a partition named 'ceph' exists
|
|
|
|
shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
|
2016-08-17 05:49:30 +08:00
|
|
|
with_items: "{{ devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-08-17 05:49:30 +08:00
|
|
|
register: parted_results
|