--- - name: upload {{app}}.zip copy: src=/var/transfer/{{app}}.zip dest={{root_dir}}/webapps/{{app}}.zip - name: check whether {{app}} exists shell: cd {{root_dir}}/webapps/ && [ -d {{app}} ] ignore_errors: true register: result - name: remove old {{app}}_backup.tgz shell: cd {{root_dir}}/webapps/ && rm -rf {{app}}_backup.tgz - name: create current {{app}}_backup.tgz when: result is succeeded shell: cd {{root_dir}}/webapps/ && tar zcf {{app}}_backup.tgz {{app}}/ - name: unzip new {{app}}.zip shell: cd {{root_dir}}/webapps/ && unzip -o -qq {{app}}.zip && rm -f {{app}}.zip