Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created September 15, 2018 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/07c0c3427aa3eb3c0abc07f76fc68279 to your computer and use it in GitHub Desktop.
Save mahemoff/07c0c3427aa3eb3c0abc07f76fc68279 to your computer and use it in GitHub Desktop.
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