---
- name: Test remove nonexistent pool
  hosts: all
  become: true
  vars:
    storage_safe_mode: false
    storage_use_partitions: true
    mount_location1: '/opt/test1'
    storage_test_skip_fingerprint: true
  tags:
    - tests::lvm

  # This tests the issue when removing nonexistent pool (with listed volumes)
  # caused crash
  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: 1

    - name: Removing nonexistent pool (with listed volumes)
      include_role:
        name: linux-system-roles.storage
      vars:
        storage_pools:
          - name: foo
            disks: "{{ unused_disks }}"
            state: absent
            volumes:
              - name: test1
                mount_point: '/opt/test1'

    - name: Verify role results
      include_tasks: verify-role-results.yml

    - name: Removing nonexistent pool
      include_role:
        name: linux-system-roles.storage
      vars:
        storage_pools:
          - name: foo
            disks: "{{ unused_disks }}"
            state: absent

    - name: Verify role results
      include_tasks: verify-role-results.yml
