-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.yml
74 lines (59 loc) · 2.06 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
- name: Set up checkin server
hosts: checkin
remote_user: root
vars:
server_user: checkinserver
home_dir: /srv/checkin
repository_url: https://github.com/SKAPfhs1920/Checkin.git
repository_path: '{{ home_dir }}/repo'
virtualenv_path: '{{ home_dir }}/venv'
domain: 'checkin-server.local'
uwsgi_socket: '{{ home_dir }}/uwsgi.sock'
tasks:
- name: Create server user
user:
name: '{{ server_user }}'
comment: 'Checkin server'
home: '{{ home_dir }}'
create_home: yes
uid: 2001
- name: Install software
apt: update_cache=yes name={{ item }} state=present
with_items:
- git
- nginx
- python3-pip
- virtualenv
- supervisor
- uwsgi
- uwsgi-plugin-python3
- name: Clone repos
become_user: '{{ server_user }}'
git: repo='{{ repository_url }}' dest='{{ repository_path }}'
- name: Install requirements
become_user: '{{ server_user }}'
pip: requirements='{{ repository_path }}/requirements.txt' virtualenv='{{ virtualenv_path }}' virtualenv_python='python3'
- name: Make sure nginx is running
service: name=nginx enabled=yes state=started
- name: Make sure supervisord is running
service: name=supervisor enabled=yes state=started
- name: Make sure static file path exists
file: path={{ home_dir }}/static state=directory
- name: Install nginx vhost confing
template: src=templates/nginx.conf.j2 dest=/etc/nginx/conf.d/{{ domain }}.conf
notify: reload nginx
- name: Install supervisor config
template: src=templates/supervisor.conf.j2 dest=/etc/supervisor/conf.d/{{ domain }}_uwsgi.conf mode=755
notify: reload uwsgi
- name: Install uwsgi config
template: src=templates/uwsgi.yml.j2 dest={{ home_dir }}/uwsgi.yml
- name: Start uwsgi server
supervisorctl: name={{ domain }}_uwsgi state=restarted
- name: Chown socket
file: path={{ uwsgi_socket }} group=www-data
handlers:
- name: reload nginx
service: name=nginx state=reloaded
- name: reload uwsgi
supervisorctl: name={{ domain }}_uwsgi state=present