-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmatplotlib.org.yml
365 lines (327 loc) · 9.84 KB
/
matplotlib.org.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
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
---
- hosts: website
vars:
caddy:
addresses:
main: "matplotlib.org"
webhook: "do.matplotlib.org"
site_dir: "/usr/share/caddy"
tls_config: "tls /etc/caddy/tls/cert.pem /etc/caddy/tls/privkey.pem"
repos:
# Key is repo name, value is the site /path/ (which defaults to the repo
# name if not set).
mpl-brochure-site:
matplotlib.github.com:
basemap:
cheatsheets:
cycler:
devdocs:
governance:
ipympl:
matplotblog:
mpl-bench:
mpl-gui:
mpl-sphinx-theme:
mpl-third-party: thirdpartypackages
pytest-mpl:
data-prototype:
vars_files:
- files/webhook_vars.yml
tasks:
# Installation tasks
# ##################
- name: Install system requirements
tags: packages
block:
- name: Enable copr
ansible.builtin.dnf:
name: "dnf-command(copr)"
state: present
- name: Enable caddy copr
community.general.copr:
name: "@caddy/caddy"
state: enabled
- name: Install server maintenance
ansible.builtin.dnf:
name:
- dnf-automatic
- fail2ban
state: present
- name: Install web server requirements
ansible.builtin.dnf:
name:
- caddy
- git
- mailcap
- python3-aiohttp
state: present
- name: Install server monitoring tools
ansible.builtin.dnf:
name:
- golang-github-prometheus
- golang-github-prometheus-alertmanager
- golang-github-prometheus-node-exporter
- grafana
# Remove this when Loki is packaged.
- podman
state: present
- name: Allow Grafana to connect to Prometheus
ansible.posix.seboolean:
name: grafana_can_tcp_connect_prometheus_port
state: true
persistent: true
# Automatic updates
# #################
- name: Enable automatic updates
ansible.builtin.systemd:
name: dnf-automatic-install.timer
enabled: true
state: started
# Firewall setup
# ##############
- name: Setup firewall
tags: firewall
block:
- name: Enable firewall
ansible.builtin.systemd:
name: firewalld.service
enabled: true
state: started
- name: Allow SSH on firewall
tags: ssh
ansible.posix.firewalld:
service: ssh
permanent: true
immediate: true
offline: true
state: enabled
- name: Allow HTTP on firewall
ansible.posix.firewalld:
service: http
permanent: true
immediate: true
offline: true
state: enabled
- name: Allow HTTPS on firewall
ansible.posix.firewalld:
service: https
permanent: true
immediate: true
offline: true
state: enabled
# SSH configuration
# #################
- name: Configure SSH
tags: ssh
ansible.builtin.copy:
src: sshd_config
dest: /etc/ssh/sshd_config.d/99-matplotlib.conf
# fail2ban setup
# ##############
- name: Setup fail2ban
tags: fail2ban
block:
- name: Configure fail2ban
ansible.builtin.copy:
src: fail2ban/jail.local
dest: /etc/fail2ban/jail.local
notify:
- Restart fail2ban
- name: Configure SSH fail2ban
ansible.builtin.template:
src: fail2ban/sshd.local.j2
dest: /etc/fail2ban/jail.d/sshd.local
notify:
- Restart fail2ban
- name: Enable fail2ban service
ansible.builtin.systemd:
name: fail2ban.service
enabled: true
state: started
# Prepare and clone Git repositories
# ##################################
- name: Setup Git repositories
tags: git
block:
- name: Create Git repository directories
ansible.builtin.file:
path: "/usr/share/caddy/{{ item }}"
state: directory
mode: 0755
owner: caddy
group: caddy
loop: "{{ repos.keys() }}"
- name: Clone Git repositories
become: true
become_user: caddy
ansible.builtin.git:
repo: "https://github.com/matplotlib/{{ item }}"
dest: "/usr/share/caddy/{{ item }}"
version: >-
{{
(item == 'matplotlib.github.com') | ternary('main', 'gh-pages')
}}
loop: "{{ repos.keys() }}"
# Caddy server setup
# ##################
- name: Caddy setup
tags: caddy
block:
- name: Configure Caddy TLS certificate directory
ansible.builtin.file:
path: /etc/caddy/tls
state: directory
mode: 0755
owner: caddy
group: caddy
- name: Configure Caddy TLS certificates
ansible.builtin.copy:
src: tls-cert.pem
dest: /etc/caddy/tls/cert.pem
mode: 0640
owner: caddy
group: caddy
notify:
- Reload Caddy
- name: Configure Caddy TLS certificates
ansible.builtin.copy:
src: tls-privkey.pem
dest: /etc/caddy/tls/privkey.pem
mode: 0640
owner: caddy
group: caddy
notify:
- Reload Caddy
- name: Configure Caddy
ansible.builtin.template:
src: Caddyfile.j2
dest: /etc/caddy/Caddyfile
validate: "caddy validate --adapter caddyfile --config %s"
notify: Reload Caddy
- name: Enable Caddy service
ansible.builtin.systemd:
name: caddy.service
enabled: true
state: started
# Webhook setup
# #############
- name: Webhook setup
tags: webhook
block:
- name: Install webhook
ansible.builtin.copy:
src: "{{playbook_dir}}/webhook/webhook.py"
dest: /usr/bin/webhook.py
mode: 0755
notify: Restart webhook
- name: Configure webhook system service
ansible.builtin.copy:
src: "{{playbook_dir}}/webhook/webhook.service"
dest: /etc/systemd/system/webhook.service
mode: 0644
notify:
- Reload systemd
- Restart webhook
- name: Configure webhook secrets
ansible.builtin.template:
src: webhook.env.j2
dest: /etc/caddy/webhook.env
mode: 0644
notify:
- Restart webhook
- name: Enable webhook service
ansible.builtin.systemd:
name: webhook.service
enabled: true
state: started
# Monitoring setup
# ################
- name: Monitoring
tags: monitoring
block:
- name: Configure Prometheus
ansible.builtin.copy:
src: prometheus.yml
dest: /etc/prometheus/prometheus.yml
mode: 0644
notify:
- Reload Prometheus
- name: Enable prometheus node exporter service
ansible.builtin.systemd:
name: prometheus-node-exporter.service
enabled: true
state: started
- name: Enable prometheus service
ansible.builtin.systemd:
name: prometheus.service
enabled: true
state: started
- name: Configure Grafana Prometheus data source
ansible.builtin.copy:
src: grafana/prometheus.yml
dest: /etc/grafana/provisioning/datasources/prometheus.yml
mode: 0640
group: grafana
notify: Restart Grafana
- name: Configure Grafana dashboard provisioning
ansible.builtin.copy:
src: grafana/dashboards.yml
dest: /etc/grafana/provisioning/dashboards/dashboards.yml
mode: 0640
group: grafana
notify: Restart Grafana
- name: Add Grafana dashboard directory
ansible.builtin.file:
path: /var/lib/grafana/dashboards
state: directory
mode: 0750
group: grafana
- name: Add Grafana dashboards
ansible.builtin.copy:
src: "grafana/{{ item }}.json"
dest: "/var/lib/grafana/dashboards/{{ item }}.json"
mode: 0640
group: grafana
loop:
- caddy
- go-metrics
- node-statistics
- name: Enable grafana service
ansible.builtin.systemd:
name: grafana-server.service
enabled: true
state: started
# Handlers restart/reload services at playbook completion
# #######################################################
handlers:
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: Restart fail2ban
ansible.builtin.systemd:
name: fail2ban
state: restarted
- name: Restart Caddy
ansible.builtin.systemd:
name: caddy
state: restarted
- name: Reload Caddy
ansible.builtin.systemd:
name: caddy
state: reloaded
- name: Reload Prometheus
ansible.builtin.systemd:
name: prometheus
state: reloaded
- name: Restart Prometheus
ansible.builtin.systemd:
name: prometheus
state: restarted
- name: Restart Grafana
ansible.builtin.systemd:
name: grafana-server
state: restarted
- name: Restart webhook
ansible.builtin.systemd:
name: webhook
state: restarted