From 4b49a246654f7356c9b3c22c3008681702a422a0 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 16 Feb 2024 15:23:26 -0500 Subject: [PATCH] fixes for boot partition sizes --- bigboot-v3.yml | 2 ++ tasks/bigboot_manage_lv.yml | 4 ++-- tasks/capture_boot_device_details.yml | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bigboot-v3.yml b/bigboot-v3.yml index 4d3fcda..0070ee1 100644 --- a/bigboot-v3.yml +++ b/bigboot-v3.yml @@ -14,3 +14,5 @@ - name: Expand the /boot partition as requested ansible.builtin.import_role: name: infra.lvm_snapshots.bigboot + vars: + bigboot_size: "{{ bigboot_size_target }}" diff --git a/tasks/bigboot_manage_lv.yml b/tasks/bigboot_manage_lv.yml index 8f702e2..a50cb5d 100644 --- a/tasks/bigboot_manage_lv.yml +++ b/tasks/bigboot_manage_lv.yml @@ -56,7 +56,7 @@ ansible.builtin.set_fact: bigboot_lv_size_in_mb: "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" - bigboot_size_in_mb: "{{ bigboot_size[:-1] }}" + bigboot_size_in_mb: "{{ bigboot_size_target[:-1] }}" - name: Check if we can shrink the logical volume block: @@ -70,7 +70,7 @@ rescue: - name: Assert there is free space available for shrinking ansible.builtin.assert: - that: (bigboot_lv_info.size_available - bigboot_size | human_to_bytes) >= 0 + that: (bigboot_lv_info.size_available - bigboot_size_target | human_to_bytes) >= 0 fail_msg: "Not enough space available on {{ bigboot_adjacent_lvm_device | trim }} for shrinking." - name: Execute Shrink_LV role to resize target logical volume diff --git a/tasks/capture_boot_device_details.yml b/tasks/capture_boot_device_details.yml index c279a5c..e200c48 100644 --- a/tasks/capture_boot_device_details.yml +++ b/tasks/capture_boot_device_details.yml @@ -1,13 +1,21 @@ --- - name: Get /boot mount information ansible.builtin.set_fact: - bigboot_boot_info: "{{ ansible_facts.mounts \ + bigboot_boot_mount: "{{ ansible_facts.mounts \ | selectattr('mount', 'equalto', '/boot') | first }}" +- name: Capture device for /boot + ansible.builtin.set_fact: + bigboot_boot_device: "{{ bigboot_boot_mount.device | regex_replace('^.*/(\\w+$)', '\\1') }}" + +- name: Capture partition side for /boot parition + ansible.builtin.set_fact: + bigboot_boot_partsize: "{{ ansible_devices[bigboot_boot_device[:-1]].partitions[bigboot_boot_device].size }}" + - name: Capture required expansion space ansible.builtin.set_fact: bigboot_expansion_diff: - "{{ bigboot_size | human_to_bytes - bigboot_boot_info.size_total | int }}" + "{{ bigboot_size | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}" - name: Convert size difference to MB ansible.builtin.set_fact: @@ -15,7 +23,7 @@ - name: Set bigboot size 4k aligned ansible.builtin.set_fact: - bigboot_size: "{{ bigboot_size_expansion_mb[:-2] \ + bigboot_size_target: "{{ bigboot_size_expansion_mb[:-2] \ | regex_replace('\\.\\d+ ', '') \ | int | get_block_size_up }}" @@ -33,4 +41,4 @@ rescue: - name: Expansion of /boot required ansible.builtin.debug: - msg: "Expanding /boot by an additional {{ bigboot_size }}." + msg: "Expanding /boot by an additional {{ bigboot_size_target }}."