On 19.05.2019 15:33, Bruno Cochofel wrote:
> 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?
The the variable vg is a string so you need
vg | int < 20
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/36ea95c8-3c71-fb5e-4392-b7a5e6365dd8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.