maint-diskspace.yaml 714 B

12345678910111213141516171819202122232425
  1. ---
  2. - name: Check disk space
  3. hosts: "{{ my_hosts | d([]) }}"
  4. tasks:
  5. - name: Check disk space available
  6. ansible.builtin.shell:
  7. cmd: |
  8. set -euo pipefail
  9. df -Ph / | awk 'NR==2 {print $5}'
  10. executable: /bin/bash
  11. changed_when: false
  12. check_mode: false
  13. register: disk_usage
  14. # - name: Send discord message when disk space is over 80%
  15. # uri:
  16. # url: "your-webhook"
  17. # method: POST
  18. # body_format: json
  19. # body: '{"content": "Disk space on {{ inventory_hostname }} is above 80%!"}'
  20. # headers:
  21. # Content-Type: application/json
  22. # status_code: 204
  23. # when: disk_usage.stdout[:-1]|int > 80