1

I am using the below ansible playbook to check the root(/) size. if it's greater than 80%, then condition should be passed. But this is not working as expected. Can someone please help me with this.

 tasks:
- name: Check the space of the root
 shell: |
 df -h / | awk -F" " '{print 5ドル}' | sed 's/%//g' | tail -1
 register: disk_output
- debug:
 msg: "the root is greater than 80%"
 when: disk_output.stdout > 80
asked Oct 22, 2020 at 17:35

1 Answer 1

3

Ansible uses Jinja2 tests and filters in conditionals.

You can use the int filter to convert the disk_output.stdout to integer and proceed to compare it with the 80 value:

 - debug:
 msg: "the root is greater than 80%"
 when: disk_output.stdout | int > 80

cheers

answered Oct 22, 2020 at 17:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.