Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show disk space and warn about disk full in Ansible
- name: show disk space
debug: msg="{{ ((mount.size_total - mount.size_available) / 1000000000) | round(1,'common') }}GB of {{ (mount.size_total / 1000000000)|round(
1, 'common') }}GB ({{ (100 * ( (mount.size_total - mount.size_available) / mount.size_available)) | round(1, 'common')}}%)"
vars:
mount: "{{ ansible_mounts | first }}"
tags: disk
- name: ensure at least 20% free
assert:
that: mount.size_available > mount.size_total|float * 0.2
msg: Disk space is near full!
vars:
mount: "{{ ansible_mounts | first }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.