Ansible 中是否可以使用带条件语句的循环?我想要的是查找特定文件的路径是否存在。如果存在,则执行循环,并且仅针对该特定文件查看条件语句。下面的代码示例
- 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
Run Code Online (Sandbox Code Playgroud) ansible ×1