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

60 lines
2.2 KiB
YAML

---
# NOTE (leseb): current behavior of ceph-disk is to fail when the device is mounted "stderr: ceph-disk: Error: Device is mounted: /dev/sdb1"
# the return code is 1, which makes sense, however ideally if ceph-disk will detect a ceph partition
# it should exist we rc=0 and don't do anything unless we do something like --force
# As as a final word, I prefer to keep the partition check instead of running ceph-disk prepare with "failed_when: false"
# I believe it's safer
#
# regex syntax uses (pat1|pat2|...|patN) for different families of device
# names, but has a common expression for partition number at the end.
# allow 2-digit partition numbers so fast SSDs can be shared by > 9 disks
# for SSD journals.
- name: check if the device is a partition
shell: "echo '{{ item }}' | egrep '/dev/(sd[a-z]{1,2}|hd[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'"
with_items: devices
changed_when: false
failed_when: false
register: ispartition
- name: check the partition status of the osd disks
shell: "parted --script {{ item }} print > /dev/null 2>&1"
with_items: devices
changed_when: false
failed_when: false
register: osd_partition_status
when:
journal_collocation or
raw_multi_journal
- name: check the partition status of the journal devices
shell: "parted --script {{ item }} print > /dev/null 2>&1"
with_items: raw_journal_devices
changed_when: false
failed_when: false
register: journal_partition_status
when: raw_multi_journal
- name: fix partitions gpt header or labels of the osd disks
shell: sgdisk --zap-all --clear --mbrtogpt -g -- {{ item.1 }}
with_together:
- osd_partition_status.results
- devices
changed_when: false
when: (journal_collocation or raw_multi_journal) and item.0.rc != 0
- name: fix partitions gpt header or labels of the journal devices
shell: sgdisk --zap-all --clear --mbrtogpt -g -- {{ item.1 }}
with_together:
- journal_partition_status.results
- raw_journal_devices
changed_when: false
when: raw_multi_journal and item.0.rc != 0
- name: if partition named 'ceph' exists
shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
with_items: devices
changed_when: false
failed_when: false
register: parted