12345678910111213141516171819202122 |
- ---
- - hosts: "{{ server }}"
- tasks:
- - name: create versioned directory
- file: path={{ deploy_folder }}/{{ build_tag }} state=directory
- - name: sync files to folder
- synchronize: src={{ project_folder}}/ dest={{ deploy_folder }}/{{ build_tag }}/ archive=yes rsync_opts=--exclude=.git
- - name: delete symlink
- file: path={{ symlink_name }} state=absent
- - name: link new site
- file: src={{ deploy_folder }}/{{ build_tag }} dest={{ symlink_name }} state=link
- - name: get list of old releases
- shell: "ls -1r {{ deploy_folder }} | tail -n +{{ releases_to_keep | int + 1 }}"
- register: ls_output
- - name: delete old versions
- file: name={{ deploy_folder }}/{{ item }} state=absent
- with_items: "{{ ls_output.stdout_lines }}"
|