quick_test/check_device.yml

51 lines
1.9 KiB
YAML

- name: Capture logical volume adjacent to /boot
ansible.builtin.shell:
cmd: |
set -o pipefail
lsblk -pl -o name,type,mountpoint {{ bigboot_boot_mount['device'][:-1] }} | grep -vi swap | grep lvm | head -1 | awk '{ print $1}'
executable: /bin/sh
changed_when: false
register: bigboot_adjacent_lvm
- name: Debug bigboot_adjacent_lvm
ansible.builtin.debug:
var: bigboot_adjacent_lvm
- name: Set adjacent LVM device name
ansible.builtin.set_fact:
bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout }}"
- name: Debug bigboot_adjacent_lvm_device
ansible.builtin.debug:
var: bigboot_adjacent_lvm_device
- name: Get logical volume mount information
ansible.builtin.set_fact:
bigboot_lv_info: "{{ ansible_facts.mounts \
| selectattr('device', 'equalto', bigboot_adjacent_lvm_device) | first }}"
- name: Debug bigboot_lv_info
ansible.builtin.debug:
var: bigboot_lv_info
# - name: Get the mount point info
# ansible.builtin.set_fact:
# shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', item.device) }}"
# - 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"
# - 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 }}'"
# - 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)
# 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 }}