-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.yml
49 lines (41 loc) · 1.36 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
- name: deploy
hosts: all
user: deploy
vars_files:
- vars/vars_prod.yml
tasks:
#
# Register unix timestamp to mark current deployment version
#
- command: date +%s
register: current_dir
#
# Clone git repo into cache dir, they rsync to current_dir deploy version
#
- git: repo={{ gitrepo }} version={{ gitbranch }} dest={{ repo_cache }} update=yes
- command: rsync -a {{ repo_cache }}/ {{ versions_dir }}/{{ current_dir.stdout }}
#
# Upload setup script into application version
#
- template: src=templates/sbin/setup.sh dest="{{ versions_dir }}/{{ current_dir.stdout }}/setup.sh" mode=0750
#
# Setup application before symlinking
#
- command: "{{ versions_dir }}/{{ current_dir.stdout }}/setup.sh"
#
# Point current symlink to current deploy version
#
- file: state=link src={{ versions_dir }}/{{ current_dir.stdout }} dest={{ project_dir }}/current
#
# Restart wsgi server with supervisord
#
- supervisorctl: name={{ app_name }}-wsgi state=restarted
sudo: True
#
# Check and remove > num_deploys in the versions_dir
#
- shell: ls -1 {{ versions_dir }} | sort -n | tac
register: last_deploy
- file: state=absent recurse=yes path={{ versions_dir }}/{{ item }}
with_items: last_deploy.stdout_lines[{{ num_deploys }}:]