I want to remove a folder only if the size is larger than a certain size. Unfortunately I can't achieve the wanted result with the stat
module.
Attempt:
---
- hosts: pluto
tasks:
- stat:
path: /home/ik/.thunderbird
register: folder
- name: Remove .thunderbird folder on host if folder size > 100MiB
file:
path: /home/ik/.thunderbird
state: absent
when: folder.stat.size > 100000000
Error:
fatal: [pluto]: FAILED! => {"msg": "The conditional check 'folder.size > 100000000' failed. The error was: error while evaluating conditional (folder.size > 100000000): 'dict object' has no attribute 'size'\n\nThe error appears to be in '/home/ik/Playbooks/susesetup.yml': line 12, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n register: folder\n - name: Remove .thunderbird folder on host if folder size > 100MiB\n ^ here\n"}
How can I solve this issue?