1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Ansible_Project/roles/ansistrano.deploy/tasks/rsync-deploy.yml

42 lines
1.4 KiB
YAML
Raw Normal View History

2022-05-02 17:37:08 +02:00
---
# Migration check from symlink deployment
- name: ANSISTRANO | Get current folder
stat:
path: "{{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}"
register: stat_current_dir
- name: ANSISTRANO | Remove current folder if it's a symlink
file:
state: absent
path: "{{ ansistrano_deploy_to }}/{{ ansistrano_current_dir }}"
when: stat_current_dir.stat.islnk is defined and stat_current_dir.stat.islnk
# 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 -F --no-times --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_flattened:
- "{{ ansistrano_shared_paths }}"
- "{{ ansistrano_shared_files }}"
# 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_flattened:
- "{{ ansistrano_shared_paths }}"
- "{{ ansistrano_shared_files }}"