webdeploy-playbook.yml 787 B

12345678910111213141516171819202122
  1. ---
  2. - hosts: "{{ server }}"
  3. tasks:
  4. - name: create versioned directory
  5. file: path={{ deploy_folder }}/{{ build_tag }} state=directory
  6. - name: sync files to folder
  7. synchronize: src={{ project_folder}}/ dest={{ deploy_folder }}/{{ build_tag }}/ archive=yes rsync_opts=--exclude=.git
  8. - name: delete symlink
  9. file: path={{ symlink_name }} state=absent
  10. - name: link new site
  11. file: src={{ deploy_folder }}/{{ build_tag }} dest={{ symlink_name }} state=link
  12. - name: get list of old releases
  13. shell: "ls -1r {{ deploy_folder }} | tail -n +{{ releases_to_keep | int + 1 }}"
  14. register: ls_output
  15. - name: delete old versions
  16. file: name={{ deploy_folder }}/{{ item }} state=absent
  17. with_items: "{{ ls_output.stdout_lines }}"