--- - name: "ensure '{{ project_dest_dir }}' exists" become: yes become_user: root file: path: '{{ project_dest_dir | realpath }}' state: directory mode: '0755' owner: stack group: stack recurse: yes when: >- ( project_src_dir | length) > 0 or ( project_git_repo | length) > 0 - name: "check '{{ project_src_dir }}' exists" stat: path: '{{ project_src_dir }}' delegate_to: localhost register: check_project_src_dir_exists when: ( project_src_dir | length) > 0 failed_when: no - become: yes become_user: stack block: - name: copy '{{ project_src_dir }}' to '{{ project_dest_dir }}' synchronize: group: no owner: no src: "{{ project_src_dir | realpath }}/." dest: "{{ project_dest_dir | realpath }}" use_ssh_args: yes recursive: yes rsync_opts: - '--exclude-from={{ project_src_dir | realpath }}/.gitignore' register: copy_project_src_dir when: check_project_src_dir_exists.stat.isdir | default(False) - name: >- fetch project sources from '{{ project_git_repo }}' to '{{ project_dest_dir }}' git: repo: '{{ project_git_repo }}' dest: '{{ project_dest_dir }}' version: '{{ project_git_version }}' force: true when: - copy_project_src_dir is skipped - ( project_git_repo | length) > 0