valide: improve device check

We know make sure that:

* devices are actually block special files
* length of dedicated_device is identical to devices

Signed-off-by: Sébastien Han <seb@redhat.com>
pull/2902/head
Sébastien Han 2018-07-18 15:59:22 +02:00 committed by mergify[bot]
parent 05852b0301
commit cf01e596b6
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,37 @@
---
- name: validate devices is actually a device
parted:
device: "{{ item }}"
unit: MiB
register: devices_parted
with_items: "{{ devices }}"
- name: fail if one of the devices is not a device
fail:
msg: "{{ item }} is not a block special file!"
when:
- item.rc != 0
with_items: "{{ devices_parted.results }}"
- name: validate dedicated_device is/are actually device(s)
parted:
device: "{{ item }}"
unit: MiB
register: dedicated_device_parted
with_items: "{{ dedicated_device }}"
when:
- osd_scenario == 'non-collocated'
- name: fail if one of the dedicated_device is not a device
fail:
msg: "{{ item }} is not a block special file!"
when:
- item.rc != 0
with_items: "{{ dedicated_device_parted.results }}"
- name: fail if dedicated_device is not the size length as devices
fail:
msg: "dedicated_device lengtth must be identical to devices's length"
when:
- osd_scenario == 'non-collocated'
- dedicated_device|length != devices|length

View File

@ -52,3 +52,6 @@
- name: include check_system.yml
include: check_system.yml
- name: include check_devices.yml
include: check_devices.yml