-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yaml
76 lines (66 loc) · 2.26 KB
/
playbook.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
---
- hosts: all
vars:
user: "vagrant"
virtualenv_dir: "/home/{{ user }}/app"
app_dir: "/home/{{ user }}"
app_name: "fvaproj"
host: "localhost"
tasks:
- name: update apt cache
apt: update_cache=yes
become: yes
become_method: sudo
- name: install packages
apt: name={{ item }} state=present
with_items:
- mongodb
- nginx
- python-virtualenv
- python-dev
- build-essential
- supervisor
become: yes
become_method: sudo
- name: create dirs structure
shell: mkdir -p {{ item }}
with_items:
- "{{ app_dir }}/app"
- "{{ app_dir }}/app/src"
- "{{ app_dir }}/conf/uwsgi"
- "{{ app_dir }}/conf/nginx"
- "{{ app_dir }}/conf/supervisord"
- "{{ app_dir }}/run"
- "{{ app_dir }}/logs"
- name: copy code
copy: src=testapp/ dest=~vagrant/app/src/ owner={{ user }}
- name: check if virtualenv already exists
stat: path={{ virtualenv_dir }}/bin/pip
register: venv_dir
- name: create virtualenv
shell: virtualenv {{ virtualenv_dir }}
when: venv_dir.stat.isreg is not defined
- name: install web application dependencies
pip: requirements=~vagrant/app/src/requirements.txt
virtualenv={{ virtualenv_dir }}
- name: put templates
template: src={{ item.src }} dest={{ item.dest }} owner={{ user }}
with_items:
- { src: 'conf/uwsgi/uwsgi.ini', dest: '{{app_dir}}/conf/uwsgi/uwsgi.ini'}
- { src: 'conf/nginx/app.conf', dest: '{{app_dir}}/conf/nginx/app.conf'}
- { src: 'conf/nginx/vhost.conf', dest: '{{app_dir}}/conf/nginx/vhost.conf'}
- name: put system templates
template: src={{ item.src }} dest={{ item.dest }} owner=root
with_items:
- { src: 'conf/sys/nginx/apps.conf', dest: '/etc/nginx/conf.d/apps.conf'}
- { src: 'conf/sys/supervisord/supervisord.conf', dest: '/etc/supervisor/conf.d/testapp.conf'}
become: yes
become_method: sudo
- name: restart nginx
action: service name=nginx state=restarted
become: yes
become_method: sudo
- name: restart supervisor
action: service name=supervisor state=restarted
become: yes
become_method: sudo