- name: Check the VolumeGroup has 5gb space
assert:
that: ansible_lvm.vgs.VG00.free_g|int >= 5
fail_msg: 'VG has no free space'
success_msg: "{{ ansible_lvm.vgs.rhel.free_g }}"
register: vg00
- name: Line in file
shell: echo -e "{{ ansible_fqdn }},VG_FREE=0" >> /tmp/failed.txt
delegate_to: localhost
when: "'FATAL' in vg00"
I need only the failed hosts to be redirected using when condition but it is not working. Any different condition will help
It seems like you are trying to use facts that do not exist (I've checked in ansible 2.9.12).
So my way of getting this to work would be:
Using shell module extensively is not recommended as Idempotence (https://en.wikipedia.org/wiki/Idempotence) is hard to achieve but for reporting purposes - why not :) .