diff --git a/tasks/capture_boot_device_details.yml b/tasks/capture_boot_device_details.yml index c66ab36..3cdc006 100644 --- a/tasks/capture_boot_device_details.yml +++ b/tasks/capture_boot_device_details.yml @@ -21,14 +21,6 @@ bigboot_expansion_diff: "{{ bigboot_size_target | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}" -- name: Convert size difference to MB - ansible.builtin.set_fact: - bigboot_size_expansion_mb: "{{ bigboot_expansion_diff | int | human_readable(unit='M') }}" - -- name: Set bigboot size 4k aligned - ansible.builtin.set_fact: - bigboot_size: "{{ bigboot_size_expansion_mb[:-2] | int | get_block_size_up }}" - - name: Validate if we need to expand boot block: - name: Set flag for Bigboot execution @@ -48,4 +40,7 @@ - name: Expansion of /boot required ansible.builtin.debug: - msg: "Will need to expand /boot by an additional {{ bigboot_size }}." + msg: > + Expansion of /boot is required. + Will attempt to increase to {{ bigboot_size_target }}, or + {{ bigboot_size_min }} at the least." diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index eea6731..d2f9438 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -47,11 +47,11 @@ # that: bigboot_lv_info.size_available > bigboot_expansion_diff | int # fail_msg: There is not enough space available for LV shrinking. -- name: Copy size target to temporary variable +- name: Set initial target size for fallback ansible.builtin.set_fact: bigboot_size_target_fallback: "{{ bigboot_size_target | human_to_bytes }}" -- name: Check for available space and fallback if needed +- name: Check available space and fallback to lower /boot size if required ansible.builtin.include_tasks: check_space_fallback.yml - name: Capture shrink and fallback sizes @@ -59,10 +59,6 @@ bigboot_lv_shrink_size: "{{ bigboot_lv_info['size_total'] - bigboot_expansion_diff | int }}" bigboot_size_target_fallback: "{{ bigboot_size_target_fallback | int | human_readable(unit='G') | regex_replace('\\sGB', 'G') }}" -# - name: Debug sizes -# ansible.builtin.debug: -# msg: "{{ bigboot_lv_shrink_size }} <-> {{ bigboot_size_target_fallback }}" - - name: Capture logical volume name ansible.builtin.shell: cmd: | @@ -109,13 +105,19 @@ - name: Verify available PE for the volume group block: - - name: Set flag for Shrink_LV execution + - name: Set required variables for shrinking the target LV ansible.builtin.set_fact: bigboot_execute_shrink_lv: false + bigboot_expansion_diff_mb: "{{ bigboot_expansion_diff | int | human_readable(unit='M') }}" - - name: Assert if we need to execute the shrink_lv role to gain free PE + - name: Debug even more sizes + ansible.builtin.debug: + msg: "{{ bigboot_lv_pe_size_in_mb[:-3] | int }} <-> {{ bigboot_expansion_diff_mb[:-3] | int }}" + + + - name: Assert if we need to shrink the logical volume to gain PE ansible.builtin.assert: - that: (bigboot_lv_pe_size_in_mb[:-3] | int | round) | int > bigboot_size[:-1] | int + that: (bigboot_lv_pe_size_in_mb[:-3] | int) >= (bigboot_expansion_diff_mb[:-3] | int) fail_msg: Not enough PE to expand /boot. rescue: diff --git a/tasks/check_space_fallback.yml b/tasks/check_space_fallback.yml index 921e7ae..8e58962 100644 --- a/tasks/check_space_fallback.yml +++ b/tasks/check_space_fallback.yml @@ -5,7 +5,7 @@ - name: Fail if /boot can't expand to at least 1GB ansible.builtin.assert: - that: bigboot_size_target_fallback | human_to_bytes > bigboot_size_min | human_to_bytes + that: bigboot_size_target_fallback | human_to_bytes >= bigboot_size_min | human_to_bytes fail_msg: "{{ bigboot_size_target_fallback | int | human_readable(unit='M') }} is less than the minimum of 1GB for /boot" - name: Verify available space and re-check if needed @@ -23,7 +23,7 @@ - name: Update required expansion space ansible.builtin.set_fact: bigboot_expansion_diff: - "{{ bigboot_size_target_fallback | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}" + "{{ (bigboot_size_target_fallback | human_to_bytes - bigboot_boot_partsize | human_to_bytes) }}" - name: Re-check disk space - RESCUE ansible.builtin.include_tasks: check_space_fallback.yml