Created
September 15, 2018 08:24
-
-
Save mahemoff/07c0c3427aa3eb3c0abc07f76fc68279 to your computer and use it in GitHub Desktop.
Show disk space and warn about disk full in Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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