---
- hosts: all
  become: true

  tasks:
    - include_role:
        name: redhat.rhel_system_roles.storage
        public: true

    - name: test lvm and xfs package deps
      include_tasks: run_blivet.yml
      vars:
        packages_only: true
        storage_pools:
          - name: foo
            type: lvm
            state: present
            disks: []
            encryption: false
            volumes:
              - name: test1
                type: lvm
                fs_type: xfs
                state: present
                mount_point: '/foo'
                encryption: false

    - name: Assert unexpected required package list is empty
      assert:
        that:
          - blivet_output.packages == ['lvm2', 'xfsprogs']
          - not blivet_output.changed
        msg: "unexpected required package list: {{ blivet_output.packages }}"

    - name: test disk and ext4 package deps
      include_tasks: run_blivet.yml
      vars:
        packages_only: true
        storage_volumes:
          - name: foo
            type: disk
            state: present
            disks: []
            fs_type: ext4
            encryption: false

    - name: Assert unexpected required package list is empty
      assert:
        that:
          - blivet_output.packages == ['e2fsprogs']
          - not blivet_output.changed
        msg: "unexpected required package list: {{ blivet_output.packages }}"

    - name: test disk and swap package deps
      include_tasks: run_blivet.yml
      vars:
        packages_only: true
        storage_volumes:
          - name: foo
            type: disk
            state: present
            disks: []
            fs_type: swap
            encryption: false

    - name: Assert unexpected required package list is empty
      assert:
        that:
          - blivet_output.packages == []
          - not blivet_output.changed
        msg: "unexpected required package list: {{ blivet_output.packages }}"
