Finalize development of shrink_lv fix; Testing

This commit is contained in:
Chris Hammer 2025-01-08 12:38:23 -05:00
parent 078da59120
commit 0606ff81b2
2 changed files with 24 additions and 17 deletions

View File

@ -0,0 +1,13 @@
---
- name: Set device for mount
ansible.builtin.set_fact:
shrink_lv_set_device: "{{ ansible_facts['mounts'] | selectattr('device', 'equalto', item['device']) | first }}"
- name: Assert that the filesystem has shrunk
ansible.builtin.assert:
# yamllint disable-line rule:line-length
that: (shrink_lv_set_device['size_total'] | int) <= (item['size'] | ansible.builtin.human_to_bytes)
fail_msg: >
Logical Volume {{ item['device'] }} was NOT shrunk as requested.
success_msg: >
Logical Volume {{ item['device'] }} has been shrunk as requested.

View File

@ -2,10 +2,10 @@
- name: Make sure the required facts are available - name: Make sure the required facts are available
ansible.builtin.setup: ansible.builtin.setup:
gather_subset: gather_subset:
- "!all" - "!all"
- "!min" - "!min"
- kernel - kernel
- mounts - mounts
- name: Run preflight checks - name: Run preflight checks
ansible.builtin.include_tasks: preflight.yaml ansible.builtin.include_tasks: preflight.yaml
@ -16,8 +16,8 @@
dest: /usr/lib/dracut/modules.d/99shrink_lv/ dest: /usr/lib/dracut/modules.d/99shrink_lv/
mode: "0554" mode: "0554"
loop: loop:
- module-setup.sh - module-setup.sh
- shrink.sh - shrink.sh
- name: Resolve and copy the shrink-start script - name: Resolve and copy the shrink-start script
ansible.builtin.template: ansible.builtin.template:
@ -39,16 +39,10 @@
- name: Retrieve mount points - name: Retrieve mount points
ansible.builtin.setup: ansible.builtin.setup:
gather_subset: gather_subset:
- "!all" - "!all"
- "!min" - "!min"
- mounts - mounts
- name: Assert that the filesystem has shrunk - name: Check if device has shrunken successfully
ansible.builtin.assert: ansible.builtin.include_tasks: check_if_shrunk.yml
# yamllint disable-line rule:line-length
that: (ansible_facts.mounts | selectattr('device', 'equalto', item.device) | map(attribute='size_total') | join | int) <= (item.size | ansible.builtin.human_to_bytes)
fail_msg: >
Logical Volume {{ item.device }} was not shrunk to {{ item.size }} as requested
success_msg: >
Logical Volume {{ item.device }} has been shrunk to {{ item.size }} as requested.
loop: "{{ shrink_lv_devices }}" loop: "{{ shrink_lv_devices }}"