fixes for boot partition sizes
All checks were successful
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-centos9) (push) Successful in 15s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-debian11) (push) Successful in 13s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-debian12) (push) Successful in 14s
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-fedora39) (push) Successful in 15s

This commit is contained in:
Chris Hammer 2024-02-16 15:23:26 -05:00
parent 8b45733501
commit 4b49a24665
3 changed files with 16 additions and 6 deletions

View File

@ -14,3 +14,5 @@
- name: Expand the /boot partition as requested - name: Expand the /boot partition as requested
ansible.builtin.import_role: ansible.builtin.import_role:
name: infra.lvm_snapshots.bigboot name: infra.lvm_snapshots.bigboot
vars:
bigboot_size: "{{ bigboot_size_target }}"

View File

@ -56,7 +56,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
bigboot_lv_size_in_mb: bigboot_lv_size_in_mb:
"{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}"
bigboot_size_in_mb: "{{ bigboot_size[:-1] }}" bigboot_size_in_mb: "{{ bigboot_size_target[:-1] }}"
- name: Check if we can shrink the logical volume - name: Check if we can shrink the logical volume
block: block:
@ -70,7 +70,7 @@
rescue: rescue:
- name: Assert there is free space available for shrinking - name: Assert there is free space available for shrinking
ansible.builtin.assert: ansible.builtin.assert:
that: (bigboot_lv_info.size_available - bigboot_size | human_to_bytes) >= 0 that: (bigboot_lv_info.size_available - bigboot_size_target | human_to_bytes) >= 0
fail_msg: "Not enough space available on {{ bigboot_adjacent_lvm_device | trim }} for shrinking." fail_msg: "Not enough space available on {{ bigboot_adjacent_lvm_device | trim }} for shrinking."
- name: Execute Shrink_LV role to resize target logical volume - name: Execute Shrink_LV role to resize target logical volume

View File

@ -1,13 +1,21 @@
--- ---
- name: Get /boot mount information - name: Get /boot mount information
ansible.builtin.set_fact: ansible.builtin.set_fact:
bigboot_boot_info: "{{ ansible_facts.mounts \ bigboot_boot_mount: "{{ ansible_facts.mounts \
| selectattr('mount', 'equalto', '/boot') | first }}" | selectattr('mount', 'equalto', '/boot') | first }}"
- name: Capture device for /boot
ansible.builtin.set_fact:
bigboot_boot_device: "{{ bigboot_boot_mount.device | regex_replace('^.*/(\\w+$)', '\\1') }}"
- name: Capture partition side for /boot parition
ansible.builtin.set_fact:
bigboot_boot_partsize: "{{ ansible_devices[bigboot_boot_device[:-1]].partitions[bigboot_boot_device].size }}"
- name: Capture required expansion space - name: Capture required expansion space
ansible.builtin.set_fact: ansible.builtin.set_fact:
bigboot_expansion_diff: bigboot_expansion_diff:
"{{ bigboot_size | human_to_bytes - bigboot_boot_info.size_total | int }}" "{{ bigboot_size | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}"
- name: Convert size difference to MB - name: Convert size difference to MB
ansible.builtin.set_fact: ansible.builtin.set_fact:
@ -15,7 +23,7 @@
- name: Set bigboot size 4k aligned - name: Set bigboot size 4k aligned
ansible.builtin.set_fact: ansible.builtin.set_fact:
bigboot_size: "{{ bigboot_size_expansion_mb[:-2] \ bigboot_size_target: "{{ bigboot_size_expansion_mb[:-2] \
| regex_replace('\\.\\d+ ', '') \ | regex_replace('\\.\\d+ ', '') \
| int | get_block_size_up }}" | int | get_block_size_up }}"
@ -33,4 +41,4 @@
rescue: rescue:
- name: Expansion of /boot required - name: Expansion of /boot required
ansible.builtin.debug: ansible.builtin.debug:
msg: "Expanding /boot by an additional {{ bigboot_size }}." msg: "Expanding /boot by an additional {{ bigboot_size_target }}."