validate: only check device when they are devices

We only validate the devices that are passed if there is a list of
devices to validate.

Signed-off-by: Sébastien Han <seb@redhat.com>
(cherry picked from commit 2888c0825f)
pull/3857/head
Sébastien Han 2018-10-12 18:32:40 +02:00 committed by mergify[bot]
parent 55d763f3f7
commit 89463939f2
2 changed files with 6 additions and 4 deletions

View File

@ -24,19 +24,20 @@
register: dedicated_device_parted register: dedicated_device_parted
with_items: "{{ dedicated_devices }}" with_items: "{{ dedicated_devices }}"
when: when:
- osd_scenario == 'non-collocated' - dedicated_devices|default([]) | length > 0
- name: fail if one of the dedicated_device is not a device - name: fail if one of the dedicated_device is not a device
fail: fail:
msg: "{{ item }} is not a block special file!" msg: "{{ item }} is not a block special file!"
with_items: "{{ dedicated_device_parted.results }}" with_items: "{{ dedicated_device_parted.results }}"
when: when:
- osd_scenario == 'non-collocated' - dedicated_devices|default([]) | length > 0
- item.failed - item.failed
- name: fail if number of dedicated_devices is not equal to number of devices - name: fail if number of dedicated_devices is not equal to number of devices
fail: fail:
msg: "Number of dedicated_devices must be equal to number of devices. dedicated_devices: {{ dedicated_devices | length }}, devices: {{ devices | length }}" msg: "Number of dedicated_devices must be equal to number of devices. dedicated_devices: {{ dedicated_devices | length }}, devices: {{ devices | length }}"
when: when:
- osd_scenario == 'non-collocated' - dedicated_devices|default([]) | length > 0
- dedicated_devices|length != devices|length - devices | length > 0
- dedicated_devices | length != devices | length

View File

@ -61,6 +61,7 @@
when: when:
- osd_group_name in group_names - osd_group_name in group_names
- not osd_auto_discovery | default(False) - not osd_auto_discovery | default(False)
- devices|default([])|length > 0
- name: include check_eth_mon.yml - name: include check_eth_mon.yml
include_tasks: check_eth_mon.yml include_tasks: check_eth_mon.yml