-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yml
58 lines (49 loc) · 1.68 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
50
51
52
53
54
55
56
57
58
- name: Deploy incubator
hosts: incubator107
user: incubator
tasks:
- set_fact: application_folder=/usr/share/nginx/incubator107
tags: cleanup
- set_fact: timestamp={{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}
- set_fact: release_path={{ application_folder }}/releases/{{ timestamp }}
- name: checkout from git
git: repo=https://github.com/cip123/incubator107 dest={{ release_path }}
- name: Symlink shared files
file:
src: "{{ application_folder }}/shared/{{ item }}"
dest: "{{ release_path }}/{{ item }}"
state: link
force: yes
with_items:
- config/database.yml
- public/system
- pids
- log
- tmp
- vendor/bundle
- name: Install bundle
command: 'bundle install --deployment --without="development test"'
args:
chdir: "{{ release_path }}"
- name: Precompile assets
command: bundle exec rake assets:precompile chdir={{ release_path }}
environment:
RAILS_ENV: production
- name: Migrate database
command: bundle exec rake db:migrate chdir={{ release_path }}
environment:
RAILS_ENV: production
- name: Symlink new release
file:
src: "{{ release_path }}"
dest: "{{ application_folder }}/current"
state: link
force: yes
- name: Restart nginx
command: sudo systemctl restart nginx
tags: nginx
- name: Cleanup
shell: "ls -1t {{ application_folder }}/releases | tail -n +5 | xargs rm -rf"
args:
chdir: "{{ application_folder }}/releases"
tags: cleanup