2014-09-05 03:14:11 +08:00
|
|
|
---
|
|
|
|
# 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
|
2015-07-29 00:21:15 +08:00
|
|
|
# As as a final word, I prefer to keep the partition check instead of running ceph-disk prepare with "failed_when: false"
|
2014-09-05 03:14:11 +08:00
|
|
|
# I believe it's safer
|
2015-10-09 18:40:57 +08:00
|
|
|
#
|
|
|
|
# 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
|
2016-02-12 05:51:23 +08:00
|
|
|
shell: "echo '{{ item }}' | egrep '/dev/({h,s,v}d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'"
|
2014-09-05 03:14:11 +08:00
|
|
|
with_items: devices
|
2015-06-26 06:26:03 +08:00
|
|
|
changed_when: false
|
2015-07-29 00:21:15 +08:00
|
|
|
failed_when: false
|
2014-09-05 03:14:11 +08:00
|
|
|
register: ispartition
|
2016-02-12 05:40:59 +08:00
|
|
|
when: not osd_auto_discovery
|
|
|
|
|
|
|
|
- name: check if the device is a partition (autodiscover disks)
|
2016-02-12 05:51:23 +08:00
|
|
|
shell: "echo '/dev/{{ item.key }}' | egrep '/dev/({h,s,v}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-02-12 05:40:59 +08:00
|
|
|
with_dict: ansible_devices
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-02-12 07:54:09 +08:00
|
|
|
register: ispartition_autodiscover
|
2016-02-12 05:40:59 +08:00
|
|
|
when:
|
|
|
|
ansible_devices is defined and
|
|
|
|
item.value.removable == "0" and
|
|
|
|
osd_auto_discovery
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2016-02-12 07:54:09 +08:00
|
|
|
# NOTE (leseb): we must do this because of
|
|
|
|
# https://github.com/ansible/ansible/issues/4297
|
|
|
|
- name: combine ispartition results
|
|
|
|
set_fact:
|
|
|
|
combined_ispartition_results: "{{ ispartition if not osd_auto_discovery else ispartition_autodiscover }}"
|
|
|
|
|
2015-11-20 23:05:30 +08:00
|
|
|
- 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
|
2016-02-12 07:54:09 +08:00
|
|
|
raw_multi_journal and not
|
|
|
|
osd_auto_discovery
|
2016-02-12 05:40:59 +08:00
|
|
|
|
|
|
|
- name: check the partition status of the osd disks (autodiscover disks)
|
|
|
|
shell: "parted --script /dev/{{ item.key }} print > /dev/null 2>&1"
|
|
|
|
with_dict: ansible_devices
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-02-12 07:54:09 +08:00
|
|
|
register: osd_partition_status_autodiscover
|
2016-02-12 05:40:59 +08:00
|
|
|
when:
|
|
|
|
journal_collocation or
|
|
|
|
raw_multi_journal and
|
|
|
|
ansible_devices is defined and
|
|
|
|
item.value.removable == "0" and
|
|
|
|
item.value.partitions|count == 0 and
|
|
|
|
osd_auto_discovery
|
2015-11-20 23:05:30 +08:00
|
|
|
|
2016-02-12 07:54:09 +08:00
|
|
|
# NOTE (leseb): we must do this because of
|
|
|
|
# https://github.com/ansible/ansible/issues/4297
|
|
|
|
- name: combine osd_partition_status results
|
|
|
|
set_fact:
|
|
|
|
combined_osd_partition_status_results: "{{ osd_partition_status if not osd_auto_discovery else osd_partition_status_autodiscover }}"
|
|
|
|
|
2015-11-20 23:05:30 +08:00
|
|
|
- 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:
|
2016-02-12 07:54:09 +08:00
|
|
|
- combined_osd_partition_status_results.results
|
2015-11-20 23:05:30 +08:00
|
|
|
- devices
|
|
|
|
changed_when: false
|
2016-02-12 05:40:59 +08:00
|
|
|
when:
|
|
|
|
(journal_collocation or raw_multi_journal) and not
|
|
|
|
osd_auto_discovery and
|
|
|
|
item.0.rc != 0
|
|
|
|
|
|
|
|
- name: fix partitions gpt header or labels of the osd disks (autodiscover disks)
|
|
|
|
shell: sgdisk --zap-all --clear --mbrtogpt -g -- "/dev/{{ item.1.key }}"
|
|
|
|
with_together:
|
2016-02-12 07:54:09 +08:00
|
|
|
- combined_osd_partition_status_results.results
|
2016-02-12 05:40:59 +08:00
|
|
|
- ansible_devices
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
journal_collocation and
|
|
|
|
osd_auto_discovery and
|
|
|
|
ansible_devices is defined and
|
|
|
|
item.value.removable == "0" and
|
|
|
|
item.value.partitions|count == 0 and
|
|
|
|
item.0.rc != 0
|
2015-11-20 23:05:30 +08:00
|
|
|
|
|
|
|
- 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
|
2016-02-12 05:40:59 +08:00
|
|
|
when:
|
|
|
|
raw_multi_journal and
|
|
|
|
item.0.rc != 0
|
2015-11-20 23:05:30 +08:00
|
|
|
|
2016-02-12 05:40:59 +08:00
|
|
|
- name: check if a partition named 'ceph' exists
|
2014-09-05 03:14:11 +08:00
|
|
|
shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
|
|
|
|
with_items: devices
|
2015-06-26 06:26:03 +08:00
|
|
|
changed_when: false
|
2015-07-29 00:21:15 +08:00
|
|
|
failed_when: false
|
2014-09-05 03:14:11 +08:00
|
|
|
register: parted
|
2016-02-12 05:40:59 +08:00
|
|
|
when: not osd_auto_discovery
|
|
|
|
|
|
|
|
- name: check if a partition named 'ceph' exists (autodiscover disks)
|
2016-02-14 06:07:44 +08:00
|
|
|
shell: "parted --script /dev/{{ item.key }} print | egrep -sq '^ 1.*ceph'"
|
2016-02-12 05:40:59 +08:00
|
|
|
with_dict: ansible_devices
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-02-12 07:54:09 +08:00
|
|
|
register: parted_autodiscover
|
2016-02-12 05:40:59 +08:00
|
|
|
when:
|
|
|
|
ansible_devices is defined and
|
|
|
|
item.value.removable == "0" and
|
|
|
|
osd_auto_discovery
|
2016-02-12 07:54:09 +08:00
|
|
|
|
|
|
|
# NOTE (leseb): we must do this because of
|
|
|
|
# https://github.com/ansible/ansible/issues/4297
|
|
|
|
- name: combine parted results
|
|
|
|
set_fact:
|
|
|
|
combined_parted_results: "{{ parted if not osd_auto_discovery else parted_autodiscover }}"
|