2023-05-25 13:48:38 +02:00
|
|
|
---
|
2024-03-03 16:54:47 +01:00
|
|
|
- name: Check disk space
|
2024-02-23 12:19:48 +01:00
|
|
|
hosts: "{{ my_hosts | d([]) }}"
|
2024-03-03 16:34:29 +01:00
|
|
|
|
2023-05-25 13:48:38 +02:00
|
|
|
tasks:
|
2024-03-03 16:54:47 +01:00
|
|
|
- name: Check disk space available
|
2024-03-03 17:49:31 +01:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: |
|
|
|
|
set -euo pipefail
|
|
|
|
df -Ph / | awk 'NR==2 {print $5}'
|
|
|
|
executable: /bin/bash
|
2024-03-03 17:57:02 +01:00
|
|
|
changed_when: false
|
|
|
|
check_mode: false
|
2023-05-25 13:48:38 +02:00
|
|
|
register: disk_usage
|
2024-03-03 16:34:29 +01:00
|
|
|
|
2024-03-03 16:54:47 +01:00
|
|
|
# - name: Send discord message when disk space is over 80%
|
2023-05-25 13:48:38 +02:00
|
|
|
# uri:
|
|
|
|
# url: "your-webhook"
|
|
|
|
# method: POST
|
|
|
|
# body_format: json
|
|
|
|
# body: '{"content": "Disk space on {{ inventory_hostname }} is above 80%!"}'
|
|
|
|
# headers:
|
|
|
|
# Content-Type: application/json
|
|
|
|
# status_code: 204
|
|
|
|
# when: disk_usage.stdout[:-1]|int > 80
|