Is it possible to have loop with conditional statement in Ansible? What I want is to find whether a path exists for a specific file. If it exists, to perform a loop, and only for that specific file to see conditional statement. Code sample below
- name: File exist
stat:
path: <path to the file or directory you want to check>
register: register_name
- name: Copy file
copy:
src: '{{ item }}'
dest: '<destination path>'
with_fileglob:
- ../spring.jar
- <perform if statement. if register_name.stat.exists, ../info.txt, else dont copy this info.txt >
# ... few other task with loop instead of with_fileglob