I'm trying to check if all the VGs on linux servers have less than 20% using the following:
---
- hosts: all
become: True
tasks:
- name: Lists VGs free percentage
debug: msg="VG {{ item.key }} has {{ (item.value.free_g|float * 100 / item.value.size_g|float)|round }}% free)"
with_dict: "{{ ansible_lvm.vgs }}"
- name: Check if free percentage is greater than 20
assert:
that:
- vg < 20
msg: VG space is less than 20%
vars:
vg: "{{ (item.value.free_g|float * 100 / item.value.size_g|float)|round }}"
with_dict: "{{ ansible_lvm.vgs }}"
but without ant good.
The first task works great but the assert doesn't.