Copy local file if exists, using ansible
问题 I'm working in a project, and we use ansible to create a deploy a cluster of servers. One of the tasks that I've to implement, is to copy a local file to the remote host, only if that file exists locally. Now I'm trying to solve this problem using this - hosts: 127.0.0.1 connection: local tasks: - name: copy local filetocopy.zip to remote if exists - shell: if [[ -f "../filetocopy.zip" ]]; then /bin/true; else /bin/false; fi; register: result - copy: src=../filetocopy.zip dest=/tmp/filetocopy