ceph-ansible/roles/ceph-osd/tasks/check_devices_static.yml

58 lines
1.9 KiB
YAML
Raw Normal View History

---
- name: check if the device is a partition
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}|fio[a-z]{1,2}[0-9]{1,2}$'"
with_items: "{{ devices }}"
changed_when: false
failed_when: false
always_run: true
register: ispartition_results
- name: check the partition status of the osd disks
shell: "parted --script {{ item.1 }} print > /dev/null 2>&1"
with_together:
- "{{ ispartition_results.results }}"
- "{{ devices }}"
changed_when: false
failed_when: false
always_run: true
register: osd_partition_status_results
when: item.0.rc != 0
# 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:
- "{{ osd_partition_status_results.results }}"
- "{{ devices }}"
changed_when: false
when:
- not item.0.get("skipped")
- item.0.get("rc", 0) != 0
- not containerized_deployment
- name: create gpt disk label
command: parted --script {{ item.1 }} mklabel gpt
with_together:
- "{{ osd_partition_status_results.results }}"
- "{{ devices }}"
changed_when: false
when:
- not item.0.get("skipped")
- item.0.get("rc", 0) != 0
- containerized_deployment
- name: check if a partition named 'ceph' exists
shell: "parted --script {{ item.1 }} print | egrep -sq '^ 1.*ceph'"
with_together:
- "{{ ispartition_results.results }}"
- "{{ devices }}"
changed_when: false
failed_when: false
always_run: true
register: parted_results
when: item.0.rc != 0