I have a list of search string separated by '\n' in a variable listofips
I wish to search for the string in a file hello.csv which is under my playbook_dir
I may be having some syntax issue which I'm not sure but below is what I tried.
- set_fact:
listofips: '10.0.0.1\n10.0.0.2\n10.0.0.3'
- set_fact:
foundips: "{{ foundips + item + ', ' }}"
when: lookup('file', "{{ playbook_dir }}/hello.csv").splitlines() | select('match', "{{ item }}") | list
loop: "{{ listofips.split('\n') }}"
Unfortunately, the search string exists in the file but ansible when condition fails to match.
I would also know if it is possible to have both the exact match or a wild card match?
Can you please suggest ?