diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 2d9c80d..846f472 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -30,7 +30,7 @@ strategy: free tasks: - - name: Expand the logical volume to support /boot expansion + - name: Shrink the logical volume to support /boot expansion ansible.builtin.debug: msg: - "device: {{ bigboot_adjacent_lvm_device }}" diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 8e0a996..1178ca0 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -13,7 +13,7 @@ when: - "'host' in ansible_virtualization_role" - - name: Expand the logical volume to support /boot expansion + - name: Shrink the logical volume to support /boot expansion ansible.builtin.import_role: name: infra.lvm_snapshots.shrink_lv vars: diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 2207983..d8854dd 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -1,18 +1,32 @@ --- -- name: Capture logical volume adjacent to /boot +- name: Capture all logical volume paritions on /boot device ansible.builtin.shell: cmd: | set -o pipefail - lsblk -pl -o name,type,mountpoint {{ bigboot_boot_mount['device'][:-1] }} \ - | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' + lsblk -pl -o name,type {{ bigboot_boot_mount['device'][:-1] }} | grep -i lvm executable: /bin/bash changed_when: false + failed_when: bigboot_adjacent_lvm['rc'] not in [0, 141] register: bigboot_adjacent_lvm - failed_when: bigboot_adjacent_lvm['rc'] not in [0,141] + +- name: Map the device to its mount point if applicable + ansible.builtin.set_fact: + bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) | combine({item | split(' ') | first: ansible_facts['mounts'] | selectattr('device', 'equalto', item | split(' ') | first) | map(attribute='mount')}) }}" + loop: "{{ bigboot_adjacent_lvm['stdout_lines'] }}" + +- name: Capture the device name of the mounted logical volumes + ansible.builtin.set_fact: + bigboot_lvm_mounts: "{{ bigboot_lvm_mounts | default([]) + [item['key']] }}" + loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}" + when: item['value'] | regex_search("[a-zA-Z]") - name: Set adjacent LVM device name ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout }}" + bigboot_adjacent_lvm_device: "{{ bigboot_lvm_mounts | first }}" + +- name: Debug bigboot_adjacent_lvm_device + ansible.builtin.debug: + var: bigboot_adjacent_lvm_device - name: Get logical volume mount information ansible.builtin.set_fact: