diff --git a/.gitignore b/.gitignore index b2046d2..0017977 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ collections/ansible_collections/rhc* roles/autofsck roles/verified_reboot *.bak +tasks/check_space_fallback_local.yml diff --git a/ansible.cfg b/ansible.cfg index eabe676..8d33521 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -14,6 +14,7 @@ timeout = 30 host_key_checking = false display_skipped_hosts = false deprecation_warnings = false +show_custom_stats = true # callback_whitelist is deprecated # we only include here for backwards compatibility diff --git a/bigboot-wip.yml b/bigboot-wip.yml deleted file mode 100644 index 87ae395..0000000 --- a/bigboot-wip.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Perform logical volume and boot parition resizing as needed - hosts: all - become: true - gather_facts: true - strategy: free - - vars_files: - - bigboot_vars.yml - - tasks: - - name: Cleanup from any previous executions - ansible.builtin.import_tasks: tasks/cleanup.yml - - - name: Shrink the logical volume to support /boot expansion - ansible.builtin.import_role: - name: infra.lvm_snapshots.shrink_lv - vars: - shrink_lv_devices: - - device: "/dev/mapper/system-root" - size: "53687091200" - - - name: Expand the /boot partition as requested - ansible.builtin.import_role: - name: infra.lvm_snapshots.bigboot - vars: - bigboot_partition_size: "{{ bigboot_size_target }}" diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 85eeee3..b9d7892 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -56,7 +56,7 @@ ansible.builtin.import_role: name: infra.lvm_snapshots.bigboot vars: - bigboot_partition_size: "{{ bigboot_size_target }}" + bigboot_partition_size: "{{ bigboot_data[inventory_hostname]['bigboot_size_target'] }}" - name: Failure on request ansible.builtin.fail: diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index a4b8224..731a4a7 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -30,6 +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 | int, '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 3bcba5b..a7ffa1e 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -42,15 +42,25 @@ bigboot_lv_info: "{{ ansible_facts.mounts \ | selectattr('device', 'equalto', bigboot_adjacent_lvm_device) | first }}" -- 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. +# - 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. + +- name: Check for available space and fallback if needed + ansible.builtin.import_tasks: check_space_fallback.yml - name: Capture shrink size for logical volume ansible.builtin.set_fact: bigboot_lv_shrink_size: "{{ bigboot_lv_info.size_total - bigboot_expansion_diff | int }}" +- 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: Capture logical volume name ansible.builtin.shell: cmd: | diff --git a/tasks/check_space_fallback.yml b/tasks/check_space_fallback.yml new file mode 100644 index 0000000..33dd9fc --- /dev/null +++ b/tasks/check_space_fallback.yml @@ -0,0 +1,26 @@ +--- +- name: Fail if /boot can't expand to at least 1GB + ansible.builtin.assert: + that: bigboot_size_target | human_to_bytes > 1073741824 + fail_msg: "{{ bigboot_size_target | int | human_readable(unit='M') }} is less than the minimum of 1GB for /boot" + +- name: Verify available space and re-check if needed + block: + - 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. + + rescue: + - name: Decrement size target by .25G + ansible.builtin.set_fact: + bigboot_size_target: "{{ bigboot_size_target | human_to_bytes - 262144000 }}" + + - name: Update required expansion space + ansible.builtin.set_fact: + bigboot_expansion_diff: + "{{ bigboot_size_target | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}" + + - name: Re-check disk space - RESCUE + ansible.builtin.include_tasks: check_space_fallback.yml + diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml index 7f86378..7a0c4bd 100644 --- a/vars/bigboot_vars.yml +++ b/vars/bigboot_vars.yml @@ -1,7 +1,7 @@ --- ansible_ssh_retries: 10 -bigboot_size_target: 1G +bigboot_size_target: 2G # Filename of disabled services log: bigboot_disabled_services_log: /var/IPE/IPU/el7to8/bigboot_disabled_services.log