-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
326 lines (284 loc) · 8.32 KB
/
Copy pathplaybook.yml
File metadata and controls
326 lines (284 loc) · 8.32 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
---
- hosts: all
become_user: root
become: yes
pre_tasks:
- name: define url
set_fact:
url: http://{{ servername }}
behat_url: http://behat.{{ servername }}
tasks:
- name: Install packages
dnf:
name:
- acl
- nginx
- postgresql-server
- postgresql
- python3-psycopg2
- php-fpm
- php-cli
- php-xml
- php-xmlrpc
- php-json
- php-gd
- php-pgsql
- php-intl
- php-soap
- php-opcache
- php-mbstring
- php-pecl-zip
- php-pecl-xdebug
- ruby
- ruby-devel
- openssl-devel
- sqlite-devel
- redhat-rpm-config
- "@C Development Tools and Libraries"
- "@lxde-desktop"
- "@base-x"
- java-openjdk
- libselinux-python
- virtualbox-guest-additions
- pigz
- "https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm"
- name: Update packages
dnf:
name: "*"
state: latest
- name: Disable SELinux
selinux:
policy: targeted
state: disabled
- name: Install config.php
template:
src: config.php.j2
dest: /vagrant/moodle/config.php
- name: Enable Virtualbox Guest Additions
service:
name: vboxservice
enabled: yes
state: started
- name: Disable xscreensaver
file:
path: /etc/xdg/lxsession/LXDE/autostart
state: absent
- name: Init database
command: postgresql-setup --initdb --unit postgresql
args:
creates: /var/lib/pgsql/data/postgresql.conf
- name: Configure DataGrip access
lineinfile:
path: /var/lib/pgsql/data/postgresql.conf
insertafter: "#listen_addresses = 'localhost'"
line: "listen_addresses = '*'"
- blockinfile:
path: /var/lib/pgsql/data/pg_hba.conf
insertafter: 'local\s+all\s+all\s+peer'
block: |
# IPv4 connections from host
host all all 10.0.0.0/8 trust
host all all 172.16.0.0/12 trust
host all all 192.168.0.0/16 trust
- name: Start database
service:
name: postgresql
enabled: yes
state: started
- name: Create database
become_user: postgres
postgresql_db:
name: moodle
- name: Create database user
become_user: postgres
postgresql_user:
name: apache
priv: ALL
db: moodle
role_attr_flags: LOGIN
- name: Increase NGINX types hash size
lineinfile:
path: /etc/nginx/nginx.conf
regexp: "types_hash_max_size.*;"
line: "types_hash_max_size 4096;"
- name: Increase NGINX upload size
lineinfile:
path: /etc/nginx/nginx.conf
line: "client_max_body_size 100M;"
insertafter: ".*types_hash_max_size.*"
- name: Install NGINX site configs
template:
src: site.conf.j2
dest: /etc/nginx/conf.d/{{ item.servername }}.conf
with_items:
- { servername: "{{ servername }}", htmldir: '/vagrant/moodle' }
- { servername: "behat.{{ servername }}", htmldir: '/vagrant/moodle' }
- { servername: "saml.{{ servername }}", htmldir: '/srv/simplesamlphp/www' }
- name: Download SimpleSAML PHP
unarchive:
src: https://simplesamlphp.org/download?latest
dest: /srv/
remote_src: yes
list_files: yes
register: archive_contents
- name: Link SimpleSAML PHP directory
file:
src: "{{ item.src }}"
path: "{{ item.path }}"
state: link
with_items:
- { src: "/srv/{{ archive_contents.files[0] }}", path: "/srv/simplesamlphp" }
- { src: "/srv/{{ archive_contents.files[0] }}/www", path: "/srv/{{ archive_contents.files[0] }}/www/simplesaml" }
- name: Configure SimpleSAML
lineinfile:
path: /srv/simplesamlphp/config/config.php
regexp: "{{ item.find }}"
line: "{{ item.replace }}"
with_items:
- { find: "'auth.adminpassword' => '123'," , replace: "'auth.adminpassword' => 'Passw0rd!'," }
- { find: "'enable.saml20-idp' => false,", replace: "'enable.saml20-idp' => true," }
- name: Add SAML metadata sources for SimpleSAML PHP
lineinfile:
path: /srv/simplesamlphp/config/config.php
line: " array('type' => 'xml', 'url' => 'http://{{ servername }}/auth/saml2/sp/metadata.php'),"
insertafter: "^\\s*array\\('type' => 'flatfile'\\),$"
- name: Enable SimpleSAML example authentication
file:
path: /srv/simplesamlphp/modules/exampleauth/enable
state: touch
- name: Configure example authentication
copy:
src: authsources.php
dest: /srv/simplesamlphp/config/authsources.php
- name: Generate locally signed SAML cert
command: openssl req -newkey rsa:2048 -new -x509 -days 3652 -nodes -out server.crt -keyout server.pem -subj "/C=NA/ST=NA/L=NA/O=NA/CN=www.example.com"
args:
chdir: /srv/simplesamlphp/cert
creates: /srv/simplesamlphp/cert/server.crt
- name: Set ownership of SAML cert to PHP-FPM
file:
owner: apache
path: "{{ item }}"
with_items:
- /srv/simplesamlphp/cert/server.crt
- /srv/simplesamlphp/cert/server.pem
- name: Enable Xdebug
blockinfile:
path: /etc/php.d/16-xdebug-options.ini
create: yes
block: |
xdebug.collect_assignments = 1
xdebug.collect_includes = 1
xdebug.collect_params = 4
xdebug.collect_return = 1
xdebug.collect_vars = 1
xdebug.idekey = vagrant
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
- name: Start web server
service:
name: nginx
enabled: yes
state: started
- name: Start PHP CGI
service:
name: php-fpm
enabled: yes
state: restarted
- name: Disable firewall
service:
name: firewalld
enabled: no
state: stopped
- name: Create Moodle data dir
file:
path: /var/www/moodledata
state: directory
owner: apache
group: apache
- name: Create Behat Moodle data dir
file:
path: /var/www/behatdata
state: directory
owner: apache
group: apache
- name: Create PHPUnit Moodle data dir
file:
path: /var/www/phpudata
state: directory
owner: apache
group: apache
- name: Install MailCatcher
gem:
name: mailcatcher
state: latest
user_install: no
- name: Install MailCatcher service
copy:
src: mailcatcher.service
dest: /etc/systemd/system/mailcatcher.service
owner: root
group: root
mode: 0755
- name: Enable MailCatcher service
service:
name: mailcatcher
enabled: yes
state: started
- name: Expose MailCatcher web interface
template:
src: reverse_proxy.conf.j2
dest: /etc/nginx/conf.d/{{ item.servername }}.conf
with_items:
- { servername: "mail.{{ servername }}", proxy_destination: 'http://127.0.0.1:1080' }
- service:
name: nginx
state: restarted
- name: Install Firefox 47.0.1
unarchive:
src: https://ftp.mozilla.org/pub/firefox/releases/47.0.1/linux-x86_64/en-GB/firefox-47.0.1.tar.bz2
remote_src: yes
dest: /opt/
- name: Add Firefox 47.0.1 to PATH
file:
src: /opt/firefox/firefox
path: /usr/local/sbin/firefox
state: link
- name: Install Selenium Server 2.53.1
get_url:
url: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
owner: vagrant
group: vagrant
dest: /opt/selenium
- name: Add apache user to vagrant group
user:
name: apache
groups: vagrant
append: yes
- name: Open up vagrant home directory to group
file:
path: /home/vagrant
state: directory
mode: 0750
- name: Set group ACL defaults for vagrant home directory
acl:
path: /home/vagrant
default: yes
etype: group
permissions: rwx
state: present
- name: Create sudo_php script for CLI
copy:
src: sudo_php
dest: /usr/sbin/sudo_php
owner: root
group: root
mode: 0755
- name: Create archive_moodle script for CLI
copy:
src: moodle_archive
dest: /usr/local/sbin/moodle_archive
owner: root
group: root
mode: 0755