forked from njl/progcom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yaml
92 lines (80 loc) · 3.13 KB
/
deploy.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
- hosts: all
become: yes
tasks:
- apt: upgrade=dist update_cache=yes
- apt: pkg={{item}} state=latest
with_items:
- nginx
- supervisor
- git
- python-dev
- htop
- build-essential
- python-pip
- python-virtualenv
- postgresql
- daemontools
- ufw
- libpq-dev
- libffi-dev
- libssl-dev
- python-psycopg2
- e2fslibs-dev
- anacron
- libblas-dev
- liblapack-dev
- gfortran
- cython
#Basic service
- service: name=postgresql state=started
- service: name=supervisor state=started
- template: src=certs/progcom.njl.us.crt dest=/etc/nginx/progcom.njl.us.crt
- template: src=certs/progcom.njl.us.key dest=/etc/nginx/progcom.njl.us.key
- template: src=deployment/nginx.conf dest=/etc/nginx/sites-enabled/default
notify: restart nginx
- lineinfile: dest=/etc/postgresql/9.5/main/pg_hba.conf
line="local all all md5"
regexp="local\s+all\s+all\s+peer"
state=present backrefs=yes
notify: restart postgresql
#Repo
- file: path=/opt/progcom state=directory owner=n group=n
- git: [email protected]:njl/progcom.git
dest=/opt/progcom accept_hostkey=True force=True
become: no
notify: restart progcom
#Virtualenv
- pip: virtualenv=/opt/progcom-venv
requirements=/opt/progcom/requirements.pip
notify: restart progcom
#Envdir
- file: path=/opt/progcom-envdir state=directory owner=n group=n
- synchronize: src=deploy-config/ dest=/opt/progcom-envdir/
delete=yes
become: no
notify: restart progcom
#Backup (Installed tarsnap by hand with `./configure #--prefix=/opt/tarsnap`)
- file: path=/opt/progcom-backup/db state=directory
- file: path=/opt/progcom-backup/logs state=directory
- file: path=/opt/progcom-backup-cache state=directory
- cron: name="backup" minute="0" hour="1" job="/opt/progcom/bin/backup >/dev/null 2>&1"
#Supervisor
- template: src=deployment/web-supervisor.conf dest=/etc/supervisor/conf.d/progcom.conf
- supervisorctl: name=progcom state=started
#us.pycon.org pull
- cron: name="pycon pull" minute="0,15,30,45" job="/opt/progcom/bin/pull >/dev/null 2>&1" state=absent
- cron: name="pycon update" minute="20" hour="7" weekday="1" job="/opt/progcom/bin/weekly_email >/dev/null 2>&1" state=absent
- name: Notify in slack channel
become: no
local_action:
module: slack
token: T0HUP6ZL6/B0JC6MH0E/hwrx6XAuyLSEnaq9zkUzMjag
msg: "Web app update deployed"
handlers:
- name: restart nginx
service: name=nginx state=restarted
- name: restart postgresql
service: name=postgresql state=restarted
- name: restart progcom
supervisorctl: name=progcom state=restarted