# SPDX-License-Identifier: MIT
# Input:
# - test_disk_min_size e.g. "1g"
# - test_disk_count e.g. 10
# - test_storage_pools - the list of pools & volumes to create
# Output:
# - unused_disks e.g. ["sda", "sdb", ..]
# - test_mnt_parent e.g. /mnt or /var/mnt
---
- name: Check if system is ostree
  stat:
    path: /run/ostree-booted
  register: __ostree_booted_stat

- name: Set mount parent
  set_fact:
    test_mnt_parent: "{{ __ostree_booted_stat.stat.exists | ternary('/var/mnt', '/mnt') }}"

- name: Run the storage role install base packages
  include_role:
    name: fedora.linux_system_roles.storage
  vars:
    storage_udevadm_trigger: true # helps with get_unused_disks, cleanup

- name: Get unused disks
  include_tasks: get_unused_disk.yml
  vars:
    min_size: "{{ test_disk_min_size }}"
    min_return: "{{ test_disk_count }}"

- name: Create LVM logical volumes under volume groups
  include_role:
    name: fedora.linux_system_roles.storage
  vars:
    storage_pools: "{{ test_storage_pools }}"
    storage_udevadm_trigger: true # helps with get_unused_disks, cleanup
