Checking free VG percentage

15 views
Skip to first unread message

Bruno Cochofel

unread,
May 19, 2019, 9:33:31 AM5/19/19
to Ansible Project
Hi, 

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.

What am I doing wrong?

Thanks,
Bruno

Kai Stian Olstad

unread,
May 19, 2019, 9:44:45 AM5/19/19
to ansible...@googlegroups.com
The the variable vg is a string so you need
vg | int < 20


--
Kai Stian Olstad

Bruno Cochofel

unread,
May 19, 2019, 11:22:10 AM5/19/19
to Ansible Project
Thanks Kai, that worked.

Bruno
Reply all
Reply to author
Forward
0 new messages