This commit is contained in:
Chris Hammer 2025-05-07 17:00:48 -04:00
parent 9008c28110
commit 2d7764c183
4 changed files with 18 additions and 14 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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:

View File

@ -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