---
- name: Test raid volume fatal errors
  hosts: all
  become: true
  vars:
    storage_safe_mode: false
    storage_use_partitions: true
    mount_location: '/opt/test1'

  tasks:
    - name: Run the role
      include_role:
        name: linux-system-roles.storage

    - name: Mark tasks to be skipped
      set_fact:
        storage_skip_checks:
          - blivet_available
          - "{{ (lookup('env',
                        'SYSTEM_ROLES_REMOVE_CLOUD_INIT') in ['', 'false']) |
                ternary('packages_installed', '') }}"
          - service_facts

    - name: Get unused disks
      include_tasks: get_unused_disk.yml
      vars:
        max_return: 2
        disks_needed: 2

    - name: Try to create a raid pool with invalid raid_level (expect failure)
      include_tasks: verify-role-failed.yml
      vars:
        __storage_failed_exception: RAID level null is an invalid value.
        __storage_failed_params:
          storage_safe_mode: false
          storage_volumes:
            - name: test1
              type: raid
              raid_level: "null"
              disks: "{{ unused_disks }}"
              mount_point: "{{ mount_location }}"
