Ansible disk usage
A handy little ansible playbook to check if all the nodes have enough free disk space and free inodes.
It gives an error when:
- free space is less than 25%
- free inodes is less than 25%
---
- name: Check Disk Usage
hosts: all
gather_facts: true
tasks:
- name: Check Disk Usage
ansible.builtin.assert:
that:
- mount.size_available >= mount.size_total * 0.25
- mount.inode_available >= mount.inode_total * 0.25
msg: 'Disk usage: {{ mount.device }}'
vars:
mount: "{{ ansible_mounts | selectattr('mount','equalto',item.mount) | list | first }}"
with_items:
- '{{ ansible_mounts }}'