I'm trying to write to task when /var partition exists. I used assert variable
- name: Apply patch if /var exist and > 300MB
yum:
name: '*'
state: latest
loop: "{{ ansible_mounts }}"
when: item.mount == "/var" and item.size_available > 300000000
It should fail or skip if /var does not exist. Which is not happening. Please suggest how to skip if /var does not exist
here's what I've done to make it work:
the commented section actually shows you the datatype you're dealing with. In this case it's a list.
To flatten the list I've used
"{{ ansible_facts['mounts'] | flatten(levels=1) }}"
since the list originally looks something like this:I've tested the playbook on my
/data*
mount points as I do not have server with/var
now available - but it works as expected.some references: