33 lines
810 B
YAML
33 lines
810 B
YAML
---
|
|
- name: Check disk space
|
|
hosts: "all"
|
|
|
|
tasks:
|
|
- name: Check disk space available
|
|
ansible.builtin.shell:
|
|
cmd: |
|
|
set -euo pipefail
|
|
df -Ph / | awk 'NR==2 {print $5}'
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
check_mode: false
|
|
register: disk_usage
|
|
|
|
- name: Diskspace is over 80%
|
|
ansible.builtin.debug:
|
|
msg: "Disk is over 80%"
|
|
when: disk_usage.stdout[:-1]|int>80
|
|
|
|
- name: Posting
|
|
ntfy:
|
|
msg: '{"content": "Disk space on {{ inventory_hostname }} is above 80%!"}'
|
|
topic: "admin-alerts"
|
|
attrs:
|
|
priority: 4
|
|
actions:
|
|
- action: view
|
|
label: "Open Mastodon"
|
|
url: "ntfy.ki5bhv.com/server"
|
|
when: disk_usage.stdout[:-1]|int>80
|
|
|