From b7b0c0a5cdcf85a5493abd8599b86900a67261da Mon Sep 17 00:00:00 2001 From: akshun Date: Fri, 26 Jan 2024 15:38:37 +0530 Subject: [PATCH] Modified playbook to give fail message when disk space is nearly full --- playbooks/disk-space.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/playbooks/disk-space.yml b/playbooks/disk-space.yml index 4ce7892..1686801 100644 --- a/playbooks/disk-space.yml +++ b/playbooks/disk-space.yml @@ -3,6 +3,11 @@ hosts: all tasks: - name: Check free disk space - shell: df -kh / | tail -n1 | awk '{print $5}' + shell: df / --output\=avail | tail -1 register: free - - debug: var=free.stdout_lines + - name: free-space + debug: + msg: Available space = "{{ free.stdout|int / 1000000 }}" + - fail: + msg: / is nearly full + when: free.stdout|int is lt 3000000