Ansible: Check Disk space
1 # checkdiskspaceall.yml
2 ---
3 - hosts: zcoin_masternodes
4 vars_files: vault.yml
5 become: yes
6 become_method: sudo
7 gather_facts: yes
8 tasks:
9 - name: Collect only facts about hardware
10 setup:
11 gather_subset:
12 - 'hardware'
13
14 - name: Test for available disk space
15 setup: filter=ansible_mounts
16
17 - name: Ensure that free space on the tested volume is greater than 15%
18 assert:
19 that:
20 - mount.size_available > mount.size_total|float * 0.05
21 msg: Disk space has reached 95% threshold
22 vars:
23 mount: "{{ ansible_mounts | selectattr('mount','equalto',item.mount) | list | first }}"
24 with_items:
25 - "{{ ansible_mounts }}"