'Get node IP based on its disk free space

I am trying to write an ansible playbook that checks for disk space on multiple servers.

This is my Ansible playbook so far:

---
- hosts: all
  become: yes
  tasks:
    - name: Check / freespace
      shell: df -h / | awk '{if($5 > 85)print (IP}'s

Basically what I want to do is as soon as the shell condition is met, I want to retrieve the IPs of all those servers that exceed 85%.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source