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
user1509613
1613 gold badges3 silver badges10 bronze badges
1 Answer 1
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
ilias-sp
6,7655 gold badges33 silver badges42 bronze badges
Sign up to request clarification or add additional context in comments.