2016-08-10 06:57:41 +08:00
|
|
|
---
|
|
|
|
- name: check if the device is a partition (autodiscover disks)
|
2017-05-24 03:39:39 +08:00
|
|
|
shell: "readlink -f /dev/{{ item.key }} | 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}$'"
|
2016-08-17 05:49:30 +08:00
|
|
|
with_dict: "{{ ansible_devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-11-27 05:16:07 +08:00
|
|
|
always_run: true
|
2016-10-06 00:16:30 +08:00
|
|
|
register: ispartition_results
|
2016-08-10 06:57:41 +08:00
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
2017-07-27 17:39:19 +08:00
|
|
|
- item.value.removable == 0
|
2016-08-10 06:57:41 +08:00
|
|
|
|
2017-06-29 23:53:44 +08:00
|
|
|
- name: check if any of the raw partitions are mounted
|
|
|
|
shell: "mount |grep -sq '^/dev/{{ item.key }} '"
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
ignore_errors: yes
|
|
|
|
with_dict: "{{ ansible_devices }}"
|
|
|
|
register: mount_cmd
|
|
|
|
changed_when: false
|
|
|
|
always_run: true
|
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
2017-07-27 17:39:19 +08:00
|
|
|
- item.value.removable == 0
|
2017-06-29 23:53:44 +08:00
|
|
|
- item.value.partitions|count == 0
|
|
|
|
- item.value.holders|count == 0
|
|
|
|
|
|
|
|
- name: fail if any of the raw partitions are mounted
|
|
|
|
fail:
|
|
|
|
msg: "OSD device autodetection failed because one or more raw partitions is mounted on the host."
|
|
|
|
with_items: "{{ mount_cmd.results }}"
|
2017-07-27 17:39:19 +08:00
|
|
|
when:
|
|
|
|
- not item.get("skipped")
|
2017-08-22 20:10:10 +08:00
|
|
|
- item.rc == 0
|
2017-06-29 23:53:44 +08:00
|
|
|
|
2016-08-10 06:57:41 +08:00
|
|
|
- name: check the partition status of the osd disks (autodiscover disks)
|
|
|
|
shell: "parted --script /dev/{{ item.key }} print > /dev/null 2>&1"
|
2016-11-03 17:16:33 +08:00
|
|
|
with_dict: "{{ ansible_devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-11-27 05:16:07 +08:00
|
|
|
always_run: true
|
2016-08-17 05:49:30 +08:00
|
|
|
register: osd_partition_status_results
|
2016-08-10 06:57:41 +08:00
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
2017-07-27 17:39:19 +08:00
|
|
|
- item.value.removable == 0
|
2016-08-10 06:57:41 +08:00
|
|
|
- item.value.partitions|count == 0
|
2017-04-04 16:33:22 +08:00
|
|
|
- item.value.holders|count == 0
|
2016-08-10 06:57:41 +08:00
|
|
|
|
|
|
|
- name: fix partitions gpt header or labels of the osd disks (autodiscover disks)
|
|
|
|
shell: "sgdisk --zap-all --clear --mbrtogpt -- '/dev/{{ item.0.item.key }}' || sgdisk --zap-all --clear --mbrtogpt -- '/dev/{{ item.0.item.key }}'"
|
|
|
|
with_together:
|
2016-08-17 05:49:30 +08:00
|
|
|
- "{{ osd_partition_status_results.results }}"
|
|
|
|
- "{{ ansible_devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
2017-07-25 23:54:26 +08:00
|
|
|
- not item.0.get("skipped")
|
|
|
|
- item.0.get("rc", 0) != 0
|
|
|
|
- item.1.value.removable == 0
|
|
|
|
- item.1.value.partitions|count == 0
|
|
|
|
- item.1.value.holders|count == 0
|
|
|
|
- not containerized_deployment
|
|
|
|
|
|
|
|
- name: create gpt disk label
|
|
|
|
command: parted --script {{ item.1 }} mklabel gpt
|
|
|
|
with_together:
|
|
|
|
- "{{ osd_partition_status_results.results }}"
|
|
|
|
- "{{ ansible_devices }}"
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
|
|
|
- not item.0.get("skipped")
|
|
|
|
- item.0.get("rc", 0) != 0
|
|
|
|
- item.1.value.removable == 0
|
|
|
|
- item.1.value.partitions|count == 0
|
|
|
|
- item.1.value.holders|count == 0
|
|
|
|
- containerized_deployment
|
2016-08-10 06:57:41 +08:00
|
|
|
|
|
|
|
- name: check if a partition named 'ceph' exists (autodiscover disks)
|
|
|
|
shell: "parted --script /dev/{{ item.key }} print | egrep -sq '^ 1.*ceph'"
|
2016-08-17 05:49:30 +08:00
|
|
|
with_dict: "{{ ansible_devices }}"
|
2016-08-10 06:57:41 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-11-27 05:16:07 +08:00
|
|
|
always_run: true
|
2016-08-17 05:49:30 +08:00
|
|
|
register: parted_results
|
2016-08-10 06:57:41 +08:00
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
2017-07-27 17:39:19 +08:00
|
|
|
- item.value.removable == 0
|