I want to copy a file to remote nodes, but only if the file exists. I copied it into /tmp/webapps/partner.war
My Task is:
- local_action: stat path="/tmp/webapps/{{ application }}.war"
register: war
- name: Copy warfile
copy: src=/tmp/webapps/{{ application }}.war dest=/tmp/deploy/{{ stage }}/{{ application }}.war
when: war.stat.exists == true
But stat always tells me, the file does not exist. If I run stat manually, it shows me the file is there.
The result:
TASK: [deploy | stat path="/tmp/webapps/{{ application }}.war"] ***************
<127.0.0.1> REMOTE_MODULE stat path="/tmp/webapps/partner.war"
<127.0.0.1> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367 && echo $HOME/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367']
<127.0.0.1> PUT /tmp/tmpzrV_Ne TO /var/lib/awx/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367/stat
<127.0.0.1> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367/stat; rm -rf /var/lib/awx/.ansible/tmp/ansible-tmp-1433920640.68-144173277081367/ >/dev/null 2>&1']
ok: [example.com -> 127.0.0.1] => {"changed": false, "stat": {"exists": false}}
What did I do wrong? :/