-
Notifications
You must be signed in to change notification settings - Fork 0
/
web2py_install-2.yml
138 lines (114 loc) · 3.69 KB
/
web2py_install-2.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
- name: web2py install
hosts: webservers
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_user: administrator
key_file: /etc/nginx/ssl/nginx.key
cert_file: /etc/nginx/ssl/nginx.crt
conf_file: /etc/nginx/sites-available/web2py
web2py_password: coco-beach
server_name: localhost
tasks:
- name: apt upgrade
become: True
apt:
upgrade: yes
update_cache: true
- name: Install Ubuntu Packages
become: True
apt:
name: [python2, python-setuptools, python-dev, build-essential]
update_cache: true
state: present
- name: Get python2 pip
get_url:
url: https://bootstrap.pypa.io/get-pip.py
dest: /home/{{ ansible_user }}/get-pip.py
- name: Install python2 pip
become: True
command:
chdir: /home/{{ ansible_user }}
cmd: python2 get-pip.py
- name: Install uwsgi via pip
pip:
name: uwsgi
executable: pip
- name: Pull web2py Repo
become: True
git:
repo: https://github.com/web2py/web2py.git
force: yes
dest: /home/www-data/web2py
- name: Add www-data user
user:
name: www-data
group: www-data
- name: Set ownership of web2py
file:
path: /home/www-data/web2py
owner: www-data
group: www-data
recurse: yes
mode: u+rwx
- name: copy wsgihandler to web2py root
become: True
copy:
src: /home/www-data/web2py/handlers/wsgihandler.py
dest: /home/www-data/web2py/
remote_src: yes
owner: www-data
group: www-data
mode: u+rwx
- name: copy routes.py
template: src=templates/routes.py.j2 dest=/home/www-data/web2py
- name: set web2py password
become: True
command:
chdir: /home/www-data/web2py
cmd: python -c "from gluon.main import save_password; save_password('{{ web2py_password }}', 443)"; logout
- name: install nginx
apt: name=nginx update_cache=yes cache_valid_time=3600
- name: create directories for ssl certificates
file: path=/etc/nginx/ssl state=directory
- name: copy TLS key
copy: src=files/nginx.key dest={{ key_file }} owner=root mode=0600
notify: restart nginx
- name: copy TLS certificate
copy: src=files/nginx.crt dest={{ cert_file }}
notify: restart nginx
- name: copy nginx config file
template: src=templates/nginx-web2py.conf.j2 dest={{ conf_file }}
notify: restart nginx
- name: copy nginx web2py configuration
file: dest=/etc/nginx/sites-enabled/web2py src={{ conf_file }} state=link
notify: restart nginx
- name: create uwsgi directory
file:
path: /etc/uwsgi
state: directory
- name: Copy uwsgi web2py ini
template: src=templates/uwsgi-web2py.ini.j2 dest=/etc/uwsgi/web2py.ini mode=0644
- name: create uwsgi configuration destination directory
file:
path: /etc/init
state: directory
- name: Copy uwsgi emperor configuration
template: src=templates/uwsgi-emperor.conf.j2 dest=/etc/init/emperor-uwsgi.conf
notify: restart uwsgi
- name: Copy uwsgi emperor service
template: src=templates/uwsgi-emperor.service.j2 dest=/etc/systemd/system/emperor.uwsgi.service
notify: restart uwsgi
- name: Enable emperor service
service:
name: emperor.uwsgi.service
enabled: true
notify: restart uwsgi
handlers:
- name: restart nginx
become: yes
service: name=nginx state=restarted
- name: restart uwsgi
become: yes
service:
name: emperor.uwsgi
state: restarted