---
- name: Capture boot and logical volume information
  hosts: all
  become: true
  gather_facts: true
  strategy: free

  vars:
    shrink_lv_device: "/dev/mapper/system-root"

  tasks:
    - name: Get the mount point info
      ansible.builtin.set_fact:
        shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', shrink_lv_device) }}"

    - name: Assert that the mount point exists
      ansible.builtin.assert:
        that: (shrink_lv_mount_info | length) == 1
        fail_msg: "Mount point {{ shrink_lv_device }} does not exist"

    - name: Get logical volume mount information
      ansible.builtin.set_fact:
        bigboot_lv_info: "{{ ansible_facts.mounts \
          | selectattr('device', 'equalto', shrink_lv_device) }}"

    - name: Assert that the mount point exists
      ansible.builtin.assert:
        that: (bigboot_lv_info | length) == 1
        fail_msg: "Mount point {{ shrink_lv_device }} does not exist"

    - name: Debug shrink_lv_mount_info
      ansible.builtin.debug:
        var: shrink_lv_mount_info

    - name: Debug bigboot_lv_info
      ansible.builtin.debug:
        var: bigboot_lv_info
