From 9c87c1311e7bea86bbafa6962dfa90c1132d6a95 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 8 Jan 2025 15:04:47 -0500 Subject: [PATCH] Updates to check_device.yml; testing --- .../roles/shrink_lv/tasks/check_device.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/collections/ansible_collections/infra/lvm_snapshots/roles/shrink_lv/tasks/check_device.yaml b/collections/ansible_collections/infra/lvm_snapshots/roles/shrink_lv/tasks/check_device.yaml index 01453f8..bb03907 100644 --- a/collections/ansible_collections/infra/lvm_snapshots/roles/shrink_lv/tasks/check_device.yaml +++ b/collections/ansible_collections/infra/lvm_snapshots/roles/shrink_lv/tasks/check_device.yaml @@ -1,20 +1,20 @@ - name: Get the mount point info ansible.builtin.set_fact: - shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', item.device) }}" + shrink_lv_mount_info: "{{ ansible_facts['mounts'] | selectattr('device', 'equalto', item['device']) | first }}" - name: Assert that the mount point exists ansible.builtin.assert: - that: (shrink_lv_mount_info | length) >= 1 - fail_msg: "Mount point {{ item.device }} does not exist" + that: (shrink_lv_mount_info | length) == 1 + fail_msg: "Mount point {{ item['device'] }} does not exist" - name: Assert that the filesystem is supported ansible.builtin.assert: - that: shrink_lv_mount_info[0].fstype in ['ext4'] - fail_msg: "Unsupported filesystem '{{ shrink_lv_mount_info[0].fstype }}' on '{{ item.device }}'" + that: shrink_lv_mount_info['fstype'] in ['ext4'] + fail_msg: "Unsupported filesystem '{{ shrink_lv_mount_info['fstype'] }}' on '{{ item['device'] }}'" - name: Assert that the filesystem has enough free space ansible.builtin.assert: - that: shrink_lv_mount_info[0].block_size * shrink_lv_mount_info[0].block_used < (item.size | ansible.builtin.human_to_bytes) + that: shrink_lv_mount_info['block_size'] * shrink_lv_mount_info['block_used'] < (item['size'] | ansible.builtin.human_to_bytes) fail_msg: > - Requested size {{ item.size }} is smaller than currently used - {{ (shrink_lv_mount_info[0].block_size * shrink_lv_mount_info[0].block_used) | ansible.builtin.human_readable }} + Requested size {{ item['size'] }} is smaller than currently used + {{ (shrink_lv_mount_info['block_size'] * shrink_lv_mount_info['block_used']) | ansible.builtin.human_readable }}