I have the below file module that touches a file on remote hosts.
- name: create file
file:
path: "/oracle/{{ inventory_hostname }}/del.tmp"
state: touch
register: direxists
- fail:
msg: "Directory missing"
when: direxists.changed == False
The issue is on the target hosts I may have /oracle
or /Oracle
folder. The letter 'o' could be case insensitive. Thus, I wanted the regex to work
path: "/[Oo]racle/{{ inventory_hostname }}/del.tmp"
But unfortunately, such regex is not supported by the file module.
I will have to fall back to shell
module & use Unix commands instead; which I was not wanting.
I wish to fail the play if both /Oracle or /oracle directories are missing. If anyone of the [Oo]racle directory exists my play should not fail.
How can I achieve this requirement?