shrink_lv/tasks/capture_boot_device_details.yml
Chris Hammer e50d15a72c
All checks were successful
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-centos9) (push) Successful in 18s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-debian11) (push) Successful in 15s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-debian12) (push) Successful in 15s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-fedora39) (push) Successful in 16s
add bigboot-v3.yml, supporting filter_plugins, and fuzzy logic
2024-02-15 21:06:58 -05:00

37 lines
1.2 KiB
YAML

---
- name: Get /boot mount information
ansible.builtin.set_fact:
bigboot_boot_info: "{{ ansible_facts.mounts \
| selectattr('mount', 'equalto', '/boot') | first }}"
- name: Capture required expansion space
ansible.builtin.set_fact:
bigboot_expansion_diff:
"{{ bigboot_size | human_to_bytes - bigboot_boot_info.size_total | int }}"
- 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] \
| regex_replace('\\.\\d+ ', '') \
| int | get_block_size_up }}"
- name: Validate if we need to expand boot
block:
- name: Assert that /boot requires expansion
ansible.builtin.assert:
that: bigboot_expansion_diff | int <= 0
fail_msg: The /boot partition will need to be resized
success_msg: The /boot partition is already at the desired size
- name: The /boot parition is already at the desired size.
ansible.builtin.meta: end_host
rescue:
- name: Expansion of /boot required
ansible.builtin.debug:
msg: "Expanding /boot by an additional {{ bigboot_size }}."