Requires: NTFY Action Plugin, Vars File

---
- name: Checking disk space.
  hosts: all
  vars_files:
    - vars/ntfy.yml
  tasks:
    - name: Check disk space available
      shell: df -h / | awk 'NR==2 {print $5}'
      register: disk_usage
 
    # Send notification when disk space is over 90%
    - name: Send notification
      ntfy:
        url: "https://ntfy.domain.tld"
        topic: "ansible"
        title: "Low Disk Space!"
        msg: "{{ inventory_hostname }} is using {{ disk_usage.stdout }} of disk space!"
        priority: 3
        token: "{{ ntfy_token }}" # Defined in vars/ntfy.yml
        attrs:
      when: disk_usage.stdout[:-1]|int >= 90 # Adjust "90" for the percentage of disk space used.