From a51d077ab22a984fd9885df5da49bfc8a3dfab0e Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jan 2024 17:34:40 -0500 Subject: [PATCH] Add validation that the requested volumes have shrunk per issue #46 - 'Validate shrink_lv after reboot' (#49) --- roles/shrink_lv/tasks/main.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/roles/shrink_lv/tasks/main.yaml b/roles/shrink_lv/tasks/main.yaml index a76ae0f..1b5dada 100644 --- a/roles/shrink_lv/tasks/main.yaml +++ b/roles/shrink_lv/tasks/main.yaml @@ -35,3 +35,20 @@ ansible.builtin.file: path: /usr/lib/dracut/modules.d/99shrink_lv state: absent + +- name: Retrieve mount points + ansible.builtin.setup: + gather_subset: + - "!all" + - "!min" + - mounts + +- name: Assert that the filesystem has shrunk + ansible.builtin.assert: + # 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 }}"