---
# Perform rsync deployment
- name: ANSISTRANO | Ensure current folder is a directory
  file: state=directory path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}

- name: ANSISTRANO | Sync release to new current path
  command: rsync -a --copy-links --delete-after "{{ ansistrano_release_path.stdout }}/" "{{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/"

# Ensure symlinks target paths is absent
- name: ANSISTRANO | Ensure shared paths targets are absent
  file: state=absent path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/{{ item }}
  with_items: "{{ ansistrano_shared_paths }}"

# Symlinks shared paths
- name: ANSISTRANO | Create softlinks for shared paths
  file: state=link path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/{{ item }} src="{{ item | regex_replace('[^\/]*', '..') }}/shared/{{ item }}"
  with_items: "{{ ansistrano_shared_paths }}"

---
# Perform rsync deployment
- name: ANSISTRANO | Ensure current folder is a directory
  file: state=directory path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}

- name: ANSISTRANO | Sync release to new current path
  synchronize: src="{{ ansistrano_release_path.stdout }}/" dest="{{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/" set_remote_user={{ ansistrano_rsync_set_remote_user }} recursive=yes delete=yes archive=yes
  delegate_to: "{{ inventory_hostname }}"

# Ensure symlinks target paths is absent
- name: ANSISTRANO | Ensure shared paths targets are absent
  file: state=absent path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/{{ item }}
  with_items: "{{ ansistrano_shared_paths }}"

# Symlinks shared paths
- name: ANSISTRANO | Create softlinks for shared paths
  file: state=link path={{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}/{{ item }} src="{{ item | regex_replace('[^\/]*', '..') }}/shared/{{ item }}"
  with_items: "{{ ansistrano_shared_paths }}"

Switch to synchronize module instead of rsync
Switch to synchronize module instead of rsync
