---
# name/path (use raw_device; encryption layer is validated separately)
- name: See whether the device node is present
  stat:
    path: "{{ storage_test_volume._raw_device }}"
    follow: true
  register: storage_test_dev

- name: Verify the presence/absence of the device node
  assert:
    that: storage_test_dev.stat.exists and storage_test_dev.stat.isblk
    msg: >-
      Incorrect device node presence for volume {{ storage_test_volume.name }}
  when: _storage_test_volume_present or storage_test_volume.type == 'disk'

- name: Verify the presence/absence of the device node
  assert:
    that: not storage_test_dev.stat.exists
    msg: >-
      Incorrect device node presence for volume {{ storage_test_volume.name }}
  when: not (_storage_test_volume_present or
             storage_test_volume.type == 'disk')

- name: Make sure we got info about this volume
  assert:
    that: storage_test_volume._raw_device in storage_test_blkinfo.info
    msg: Failed to gather info about volume '{{ storage_test_volume.name }}'
  when: _storage_test_volume_present

- name: Process volume type (set initial value) (1/2)
  set_fact:
    st_volume_type: "{{ storage_test_volume.type }}"

- name: Process volume type (get RAID value) (2/2)
  set_fact:
    st_volume_type: "{{ storage_test_volume.raid_level }}"
  when: storage_test_volume.type == "raid"

- name: Verify the volume's device type
  assert:
    that: storage_test_blkinfo.info[storage_test_volume._raw_device].type ==
      st_volume_type
  when: _storage_test_volume_present

# disks
#   partition: ??
#   lvm: n/a
#   disk: identity
