---
- name: Test raid pool fatal errors
  hosts: all
  become: true
  vars:
    storage_safe_mode: false
    storage_use_partitions: true
    mount_location1: '/opt/test1'
    mount_location2: '/opt/test2'
    mount_location3: '/opt/test3'
    volume1_size: '2g'
    volume3_size: '3g'
    volume2_size: '3g'
  tags:
    - tests::lvm

  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_params:
          storage_pools:
            - name: vg1
              disks: "{{ unused_disks }}"
              type: lvm
              raid_level: fail
              state: present
              volumes:
                - name: lv1
                  size: "{{ volume1_size }}"
                  mount_point: "{{ mount_location1 }}"
                - name: lv2
                  size: "{{ volume2_size }}"
                  mount_point: "{{ mount_location2 }}"
                - name: lv3
                  size: "{{ volume3_size }}"
                  mount_point: "{{ mount_location3 }}"
