-
-
Save TheRojam/f3e7d3770b74bcc00d7376dd62244fb3 to your computer and use it in GitHub Desktop.
Ansible playbook that checks if there is less than 95% free disk space
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
# checkdiskspaceall.yml | |
--- | |
- hosts: zcoin_masternodes | |
vars_files: vault.yml | |
become: yes | |
become_method: sudo | |
gather_facts: yes | |
tasks: | |
- name: Collect only facts about hardware | |
setup: | |
gather_subset: | |
- 'hardware' | |
- name: Test for available disk space | |
setup: filter=ansible_mounts | |
- name: Ensure that free space on the tested volume is greater than 15% | |
assert: | |
that: | |
- mount.size_available > mount.size_total|float * 0.05 | |
msg: Disk space has reached 95% threshold | |
vars: | |
mount: "{{ ansible_mounts | selectattr('mount','equalto',item.mount) | list | first }}" | |
with_items: | |
- "{{ ansible_mounts }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment