From 2d7764c1832c43561d106e6f2e9df4acd157acb7 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 7 May 2025 17:00:48 -0400 Subject: [PATCH] Updates --- bigboot_setup_environment.yml | 2 +- tasks/capture_lv_device_details.yml | 22 ++++++++++++---------- tasks/check_space_fallback.yml | 6 +++--- vars/bigboot_vars.yml | 2 ++ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index 6ffcb8e..6888ab9 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -30,7 +30,7 @@ 'bigboot_adjacent_lvm_device': bigboot_adjacent_lvm_device, 'bigboot_lv_shrink_size': bigboot_lv_shrink_size | int, 'bigboot_pv': bigboot_pv, - 'bigboot_size_target': bigboot_size_target, + 'bigboot_size_target': bigboot_size_target_fallback, 'ip_addresses': ansible_all_ipv4_addresses, 'server_hostname': ansible_hostname } diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 5a93017..eea6731 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -54,16 +54,14 @@ - name: Check for available space and fallback if needed ansible.builtin.include_tasks: check_space_fallback.yml -- name: Capture shrink size for logical volume +- name: Capture shrink and fallback sizes ansible.builtin.set_fact: - bigboot_lv_shrink_size: "{{ bigboot_lv_info.size_total - bigboot_expansion_diff | int }}" + 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 bigboot_lv_shrink_size - ansible.builtin.debug: - msg: "{{ bigboot_lv_shrink_size | int | human_readable(unit='M') }}" - -- name: Kill the play - ansible.builtin.meta: end_host +# - name: Debug sizes +# ansible.builtin.debug: +# msg: "{{ bigboot_lv_shrink_size }} <-> {{ bigboot_size_target_fallback }}" - name: Capture logical volume name ansible.builtin.shell: @@ -76,7 +74,7 @@ - name: Format logical volume name ansible.builtin.set_fact: - bigboot_lv_vg_name: "{{ bigboot_lv_vg_name.stdout | regex_replace('VG\\s+Name\\s+(.*)$', '\\1') }}" + bigboot_lv_vg_name: "{{ bigboot_lv_vg_name['stdout'] | regex_replace('VG\\s+Name\\s+(.*)$', '\\1') }}" - name: Capture volume group free PE ansible.builtin.shell: @@ -98,13 +96,17 @@ # Free PE / Size 189 / 756.00 MiB" # Free PE / Size 414 / <1.62 GiB # Free PE / Size 0 / 0 - bigboot_lv_vg_free_pe: "{{ bigboot_lv_vg_free_pe.stdout | regex_replace('^.*/.*/\\s+[<]?(.*)', '\\1') }}" + bigboot_lv_vg_free_pe: "{{ bigboot_lv_vg_free_pe['stdout'] | regex_replace('^.*/.*/\\s+[<]?(.*)', '\\1') }}" - name: Get size in MB for PE and ansible.builtin.set_fact: bigboot_lv_pe_size_in_mb: "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" +# - name: Debug size vars +# ansible.builtin.debug: +# msg: "{{ bigboot_lv_pe_size_in_mb[:-3] | int | round }} <-> {{ bigboot_size[:-1] }}" + - name: Verify available PE for the volume group block: - name: Set flag for Shrink_LV execution diff --git a/tasks/check_space_fallback.yml b/tasks/check_space_fallback.yml index 5af957e..921e7ae 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 > 1073741824 + 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 @@ -13,12 +13,12 @@ - name: Assert that there is space on the logical volume for shrinkage ansible.builtin.assert: that: bigboot_lv_info['size_available'] > bigboot_expansion_diff | int - fail_msg: There is not enough space available for LV shrinking. + fail_msg: There is not enough free space available to shrink the filesystem rescue: - name: Decrement size target by .25G ansible.builtin.set_fact: - bigboot_size_target_fallback: "{{ bigboot_size_target_fallback | human_to_bytes - 262144000 }}" + bigboot_size_target_fallback: "{{ bigboot_size_target_fallback | human_to_bytes - bigboot_size_decrement | human_to_bytes }}" - name: Update required expansion space ansible.builtin.set_fact: diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml index 7a0c4bd..048b6fe 100644 --- a/vars/bigboot_vars.yml +++ b/vars/bigboot_vars.yml @@ -2,6 +2,8 @@ ansible_ssh_retries: 10 bigboot_size_target: 2G +bigboot_size_min: 1G +bigboot_size_decrement: 250M # Filename of disabled services log: bigboot_disabled_services_log: /var/IPE/IPU/el7to8/bigboot_disabled_services.log