diff --git a/.gitignore b/.gitignore index 753c812..e4a957a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ inventory/* +*.bak diff --git a/bigboot-v2.yml b/bigboot-v2.yml new file mode 100644 index 0000000..58f5f78 --- /dev/null +++ b/bigboot-v2.yml @@ -0,0 +1,44 @@ +--- +- name: Resize /boot partition on target host + hosts: all + become: true + gather_facts: true + + tasks: + - name: Resize boot partition + block: + - name: Execute Bigboot role to resize /boot + ansible.builtin.import_role: + name: infra.lvm_snapshots.bigboot + + rescue: + - name: Get the target device information and calculate padding + ansible.builtin.set_fact: + bigboot_shrink_target_info: "{{ ansible_facts.mounts \ + | selectattr('device', 'equalto', bigboot_shrink_target) | first }}" + bigboot_size_padded: (bigboot_size | human_to_bytes * bigboot_shrink_padding) | int + + - name: Calculate the new logical volume size + ansible.builtin.set_fact: + shrink_lv_volume_size: "{{ (bigboot_shrink_target_info.size_total - bigboot_size_padded | int) \ + | ansible.builtin.human_readable | ansible.builtin.regex_replace(' ', '') }}" + + - name: Show resize information + ansible.builtin.debug: + msg: "Shrinking {{ bigboot_shrink_target }} from \ + {{ bigboot_shrink_target_info.size_total | ansible.builtin.human_readable }} to \ + {{ shrink_lv_volume_size[:-1] | ansible.builtin.regex_replace('^(\\d+)\\.\\d+(\\w).*', '\\1\\2') }} \ + to expand /boot partition by {{ bigboot_size }}." + + - name: Execute Shrink_LV role to resize target logical volume + ansible.builtin.import_role: + name: infra.lvm_snapshots.shrink_lv + vars: + shrink_lv_devices: + - device: "{{ bigboot_shrink_target }}" + size: "{{ shrink_lv_volume_size[:-1] \ + | ansible.builtin.regex_replace('^(\\d+)\\.\\d+(\\w).*', '\\1\\2') }}" + + - name: Execute Bigboot role to resize /boot + ansible.builtin.import_role: + name: infra.lvm_snapshots.bigboot diff --git a/group_vars/all b/group_vars/all new file mode 100644 index 0000000..cdf6b92 --- /dev/null +++ b/group_vars/all @@ -0,0 +1,6 @@ +--- +# We use padding just to ensure that there's available +# space to expand /boot to. +# +# By default the value is 1.10, or 10% +bigboot_shrink_padding: 1.10