-
Notifications
You must be signed in to change notification settings - Fork 340
/
main.yml
669 lines (556 loc) · 22.8 KB
/
main.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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
# .. Copyright (C) 2021 David Härdeman <david@hardeman.nu>
# .. Copyright (C) 2020 CipherMail B.V. <https://www.ciphermail.com/>
# .. Copyright (C) 2021 DebOps <https://debops.org/>
# .. SPDX-License-Identifier: GPL-3.0-only
# .. _rspamd__ref_defaults:
# debops.rspamd default variables [[[
# ===================================
# .. contents:: Sections
# :local:
#
# .. include:: ../../../../includes/global.rst
# Packages and installation [[[
# -----------------------------
# .. envvar:: rspamd__packages [[[
#
# List of additional APT packages that should be installed with rspamd.
rspamd__packages: []
# ]]]
# .. envvar:: rspamd__base_packages [[[
#
# APT packages required for the rspamd installation.
rspamd__base_packages:
- 'rspamd'
- '{{ "bind9-dnsutils" if rspamd__dkim_update_method is search("nsupdate") else [] }}'
- '{{ "krb5-user" if rspamd__dkim_update_method == "nsupdate_gsstsig" else [] }}'
# ]]]
# ]]]
# DKIM configuration [[[
# -----------------------
# .. envvar:: rspamd__dkim_enabled [[[
#
# Whether to enable DKIM signing of messages. Note that this defaults to
# false because DKIM requires some manual configuration, see
# :ref:`rspamd__ref_dkim` for more details.
rspamd__dkim_enabled: False
# ]]]
# .. envvar:: rspamd__dkim_domains [[[
#
# DKIM domains to generate, manage and use signing keys for.
rspamd__dkim_domains: [ '{{ ansible_domain }}' ]
# ]]]
# .. envvar:: rspamd__dkim_log_dir [[[
#
# Absolute path to the directory which contains DKIM logs.
rspamd__dkim_log_dir: '/var/log/rspamd'
# ]]]
# .. envvar:: rspamd__dkim_keygen_default_configuration [[[
#
# The default configuration for the ``rspamd-dkim-keygen`` script.
rspamd__dkim_keygen_default_configuration:
- name: 'key_directory'
value: '/var/lib/rspamd/dkim/'
- name: 'key_archive'
value: '/var/lib/rspamd/dkim-archive/'
- name: 'update_script'
value: '/usr/local/sbin/rspamd-dkim-update'
- name: 'future_config'
value: 'dkim-future.conf'
- name: 'active_config'
value: 'dkim-active.conf'
- name: 'expired_config'
value: 'dkim-expired.conf'
- name: 'future_period'
value: 1
- name: 'active_period'
value: 3
- name: 'expired_period'
value: 1
- name: 'domains'
value: '{{ rspamd__dkim_domains }}'
- name: 'key_types'
value:
- { type: 'ed25519' }
- { type: 'rsa', extra_args: [ '--bits', '2048' ] }
# ]]]
# .. envvar:: rspamd__dkim_keygen_configuration [[[
#
# The :command:`rspamd` configuration options defined for all hosts in the
# Ansible inventory.
rspamd__dkim_keygen_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_keygen_group_configuration [[[
#
# The :command:`rspamd` configuration options defined for all hosts in a
# specific Ansible inventory group.
rspamd__dkim_keygen_group_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_keygen_host_configuration [[[
#
# The :command:`rspamd` configuration options defined for a specific host
# in the Ansible inventory.
rspamd__dkim_keygen_host_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_keygen_combined_configuration [[[
#
# This variable combines other :command:`rspamd` configuration options and
# is used by the role template to generate the configuration snippets in
# :file:`/etc/rspamd/local.d`.
rspamd__dkim_keygen_combined_configuration: '{{
rspamd__dkim_keygen_default_configuration
+ rspamd__dkim_keygen_configuration
+ rspamd__dkim_keygen_group_configuration
+ rspamd__dkim_keygen_host_configuration }}'
# ]]]
# .. envvar:: rspamd__dkim_update_method [[[
#
# The method to use to publish/remove DKIM keys as DNS RRs.
#
# Supported values are:
#
# log
# Key updates will simply be logged to a file.
# email
# Emails will be sent to the admin email address for manual handling.
# nsupdate
# The :command:`nsupdate` tool will be used to update DNS RRs as necessary.
# nsupdate_tsig
# Same as ``nsupdate``, but a ``TSIG`` or ``SIG(0)`` key will be used to
# authenticate the update requests.
# nsupdate_gsstsig
# Same as ``nsupdate``, but ``GSS-TSIG`` (Kerberos credentials) will be
# used to authenticate the update requests.
#
# Note that the various ``nsupdate`` methods most likely require some manual
# configuration of the DNS server to trust this host to make the required
# updates and/or to create suitable key material/keytabs on the Ansible
# controller. See :ref:`rspamd__ref_configuration` for more details.
rspamd__dkim_update_method: 'email'
# ]]]
# .. envvar:: rspamd__dkim_update_default_configuration [[[
#
# The default configuration for the ``rspamd-dkim-update`` script.
rspamd__dkim_update_default_configuration:
- name: 'method'
value: '{{ rspamd__dkim_update_method }}'
- name: 'log_file'
value: '{{ rspamd__dkim_log_dir + "/rspamd-dkim-update.log" }}'
- name: 'email_to'
value: '{{ ansible_local.core.admin_public_email[0]
| d("root@" + ansible_domain) }}'
- name: 'email_from'
value: '{{ "noreply@" + ansible_domain }}'
- name: 'email_host'
value: 'localhost'
- name: 'email_port'
value: 25
- name: 'email_subject'
value: 'Rspamd DKIM DNS updates'
- name: 'nsupdate_keyfile'
value: '{{ "" if rspamd__dkim_update_method in ["email", "nsupdate"]
else "/etc/rspamd/dkim_dns_key" }}'
- name: 'nsupdate_gsstsig_princ'
value: '{{ "" if rspamd__dkim_update_method != "nsupdate_gsstsig"
else "rspamd@" + ansible_domain|upper }}'
- name: 'nsupdate_ttl'
value: 3600
- name: 'nsupdate_server'
value: '{{ ansible_dns.nameservers[0] | d("") }}'
# ]]]
# .. envvar:: rspamd__dkim_update_configuration [[[
#
# The :command:`rspamd` configuration options defined for all hosts in the
# Ansible inventory.
rspamd__dkim_update_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_update_group_configuration [[[
#
# The :command:`rspamd` configuration options defined for all hosts in a
# specific Ansible inventory group.
rspamd__dkim_update_group_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_update_host_configuration [[[
#
# The :command:`rspamd` configuration options defined for a specific host
# in the Ansible inventory.
rspamd__dkim_update_host_configuration: []
# ]]]
# .. envvar:: rspamd__dkim_update_combined_configuration [[[
#
# This variable combines other :command:`rspamd` configuration options and
# is used by the role template to generate the configuration snippets in
# :file:`/etc/rspamd/local.d`.
rspamd__dkim_update_combined_configuration: '{{
rspamd__dkim_update_default_configuration
+ rspamd__dkim_update_configuration
+ rspamd__dkim_update_group_configuration
+ rspamd__dkim_update_host_configuration }}'
# ]]]
# ]]]
# Redis configuration [[[
# -----------------------
# .. envvar:: rspamd__redis_host [[[
#
# The hostname of the Redis server.
rspamd__redis_host: '{{ ansible_local.redis_server.host|d("127.0.0.1") }}'
# ]]]
# .. envvar:: rspamd__redis_port [[[
#
# The port which the Redis server is listening to.
rspamd__redis_port: '{{ ansible_local.redis_server.port|d("6379") }}'
# ]]]
# .. envvar:: rspamd__redis_password [[[
#
# The Redis authentication password.
rspamd__redis_password: '{{ ansible_local.redis_server.password|d("") }}'
# ]]]
# .. envvar:: rspamd__redis_db [[[
#
# The Redis db to use.
rspamd__redis_db: '0'
# ]]]
# ]]]
# Service configuration [[[
# -------------------------
# These variables define the contents of the :file:`/etc/rspamd/local.d` and
# :file:`/etc/rspamd/override.d` configuration directories. See
# :ref:`rspamd__ref_configuration` and the `Rspamd configuration documentation
# <https://rspamd.com/doc/configuration/>`_
# for further details.
# .. envvar:: rspamd__default_local_configuration [[[
#
# The default :command:`rspamd` :file:`local.d` configuration.
rspamd__default_local_configuration:
- file: 'worker-proxy.inc'
comment: |
Proxy worker configuration
https://rspamd.com/doc/workers/rspamd_proxy.html
options:
- name: 'bind_socket'
value: 'localhost:11332'
- name: 'milter'
value: True
- name: 'timeout'
value: 120
- name: 'upstream "local"'
options:
- name: 'default'
value: True
- name: 'self_scan'
value: True
- file: 'worker-controller.inc'
comment: |
Controller worker configuration
https://rspamd.com/doc/workers/controller.html
options:
- name: 'password'
value: '{{ rspamd__controller_password_hash }}'
- file: 'redis.conf'
comment: |
Redis configuration
https://rspamd.com/doc/configuration/redis.html
options:
- name: 'servers'
value: '{{ rspamd__redis_host}}:{{ rspamd__redis_port }}'
- name: 'db'
value: '{{ rspamd__redis_db }}'
- name: 'password'
value: '{{ rspamd__redis_password }}'
- file: 'milter_headers.conf'
comment: |
Milter headers configuration
https://rspamd.com/doc/modules/milter_headers.html
options:
- name: 'use'
value: [ 'x-spamd-bar', 'x-spam-level', 'authentication-results' ]
- name: 'authenticated_headers'
value: [ 'authentication-results' ]
- file: 'dkim_signing.conf'
comment: |
DKIM signing configuration
https://rspamd.com/doc/modules/dkim_signing.html
state: '{{ "present" if rspamd__dkim_enabled|d(False) else "absent" }}'
options:
- name: 'allow_username_mismatch'
value: True
- name: 'include_dkim_keys'
raw: '.include(try=true,priority=1,duplicate=merge) "/var/lib/rspamd/dkim/dkim-active.conf"'
- file: 'arc.conf'
comment: |
ARC signature check configuration
https://rspamd.com/doc/modules/arc.html
state: '{{ "present" if rspamd__dkim_enabled|d(False) else "absent" }}'
options:
- name: 'allow_username_mismatch'
value: True
- name: 'include_dkim_keys'
raw: '.include(try=true,priority=1,duplicate=merge) "/var/lib/rspamd/dkim/dkim-active.conf"'
# ]]]
# .. envvar:: rspamd__local_configuration [[[
#
# The default :command:`rspamd` :file:`local.d` configuration defined for all
# hosts in the Ansible inventory.
rspamd__local_configuration: []
# ]]]
# .. envvar:: rspamd__group_local_configuration [[[
#
# The default :command:`rspamd` :file:`local.d` configuration defined for all
# hosts in a specific Ansible inventory group.
rspamd__group_local_configuration: []
# ]]]
# .. envvar:: rspamd__host_local_configuration [[[
#
# The default :command:`rspamd` :file:`local.d` configuration defined for a
# specific host in the Ansible inventory.
rspamd__host_local_configuration: []
# ]]]
# .. envvar:: rspamd__combined_local_configuration [[[
#
# This variable combines other :command:`rspamd` configuration options and
# is used by the role template to generate the configuration snippets in
# :file:`/etc/rspamd/local.d`.
rspamd__combined_local_configuration: '{{ rspamd__default_local_configuration
+ rspamd__local_configuration
+ rspamd__group_local_configuration
+ rspamd__host_local_configuration }}'
# ]]]
# .. envvar:: rspamd__default_override_configuration [[[
#
# The default :command:`rspamd` :file:`override.d` configuration.
rspamd__default_override_configuration: []
# ]]]
# .. envvar:: rspamd__override_configuration [[[
#
# The default :command:`rspamd` :file:`override.d` configuration defined for
# all hosts in the Ansible inventory.
rspamd__override_configuration: []
# ]]]
# .. envvar:: rspamd__group_override_configuration [[[
#
# The default :command:`rspamd` :file:`override.d` configuration defined for
# all hosts in a specific Ansible inventory group.
rspamd__group_override_configuration: []
# ]]]
# .. envvar:: rspamd__host_override_configuration [[[
#
# The default :command:`rspamd` :file:`override.d` configuration defined for a
# specific host in the Ansible inventory.
rspamd__host_override_configuration: []
# ]]]
# .. envvar:: rspamd__combined_override_configuration [[[
#
# This variable combines other :command:`rspamd` configuration options and
# is used by the role template to generate the configuration snippets in
# :file:`/etc/rspamd/override.d`.
rspamd__combined_override_configuration: '{{ rspamd__default_override_configuration
+ rspamd__override_configuration
+ rspamd__group_override_configuration
+ rspamd__host_override_configuration }}'
# ]]]
# .. envvar:: rspamd__controller_password [[[
#
# This variable controls the password necessary to access e.g. the web-based
# user interface of :command:`rspamd`. Note that the WebUI is only accessible
# via ``http://localhost:11334/``, so for remote access, a :command:`ssh`
# tunnel or `local proxy server`__ is necessary. The latter can be configured
# automatically by this role (see :envvar:`rspamd__nginx_enabled` below).
#
# .. __: https://rspamd.com/doc/faq.html#how-to-use-the-webui-behind-a-proxy-server
rspamd__controller_password: '{{ lookup("password",
secret
+ "/credentials/"
+ inventory_hostname
+ "/rspamd/controller_password"
+ " chars=ascii_letters,digits"
+ " length=32") }}'
# ]]]
# .. envvar:: rspamd__controller_password_salt [[[
#
# The salt used to hash the :envvar:`rspamd__controller_password`.
# The default might look complicated, but it's a workaround for
# `Ansible issue #36129`__.
#
# .. __: https://github.com/ansible/ansible/issues/36129
rspamd__controller_password_salt: '{{ (lookup("password",
secret
+ "/credentials/"
+ inventory_hostname
+ "/rspamd/salt"
+ " chars=ascii_letters,digits"
+ " length=21"))[:21]
+ ("Oeu"
| shuffle(seed=inventory_hostname)
| join)[1] }}'
# ]]]
# .. envvar:: rspamd__controller_password_hash [[[
#
# The hashed version of :envvar:`rspamd__controller_password`. If you want to
# set a password manually, you probably want to change that variable instead.
rspamd__controller_password_hash: '{{ rspamd__controller_password
| password_hash("bcrypt",
salt=rspamd__controller_password_salt) }}'
# ]]]
# .. envvar:: rspamd__nginx_enabled [[[
#
# If enabled, :command:`nginx` will be setup to provide remote access to
# the WebUI of :command:`rspamd`.
rspamd__nginx_enabled: False
# ]]]
# .. envvar:: rspamd__nginx_fqdns [[[
#
# List of FQDNs which :command:`nginx` should use to make the WebUI available.
rspamd__nginx_fqdns:
- 'rspamd.{{ ansible_domain }}'
- '{{ ansible_hostname }}-rspamd.{{ ansible_domain }}'
# ]]]
# .. envvar:: rspamd__nginx_access_policy [[[
#
# The nginx access policy, by default none.
rspamd__nginx_access_policy: ''
# ]]]
# .. envvar:: rspamd__proxy_allow [[[
#
# List of IP addresses or CIDR subnets which are allowed to connect to
# :command:`rspamd`'s ``proxy`` worker remotely. If the list is empty, remote
# connections are denied. Note that this only influences the firewall settings,
# further configuration is still necessary to make :command:`rspamd` actually
# listen for remote connections (see the ``bind_socket`` and ``secure_ip``
# options in the `workers documentation`__).
#
# .. __: https://rspamd.com/doc/workers/
rspamd__proxy_allow: []
# ]]]
# .. envvar:: rspamd__normal_allow [[[
#
# Same as :envvar:`rspamd__proxy_allow`, but for the ``normal`` worker.
rspamd__normal_allow: []
# ]]]
# .. envvar:: rspamd__controller_allow [[[
#
# Same as :envvar:`rspamd__proxy_allow`, but for the ``controller`` worker.
rspamd__controller_allow: []
# ]]]
# .. envvar:: rspamd__fuzzy_allow [[[
#
# Same as :envvar:`rspamd__proxy_allow`, but for the ``fuzzy`` worker.
rspamd__fuzzy_allow: []
# ]]]
# ]]]
# Configuration for other Ansible roles [[[
# -----------------------------------------
# .. envvar:: rspamd__logrotate__dependent_config [[[
#
# Configuration for the :ref:`debops.logrotate` role.
rspamd__logrotate__dependent_config:
- filename: 'rspamd-dkim'
logs: '{{ rspamd__dkim_log_dir + "/rspamd-dkim-update.log" }}'
options: |
notifempty
missingok
yearly
maxsize 16M
rotate 10
compress
comment: 'Rspamd DKIM key rotation logs'
# ]]]
# .. envvar:: rspamd__etc_services__dependent_list [[[
#
# Configuration for the :ref:`debops.etc_services` role.
rspamd__etc_services__dependent_list:
- name: 'rspamd-proxy'
port: '11332'
protocols: [ 'tcp' ]
comment: 'Added by debops.rspamd Ansible role.'
- name: 'rspamd-normal'
port: '11333'
protocols: [ 'tcp' ]
comment: 'Added by debops.rspamd Ansible role.'
- name: 'rspamd-controller'
port: '11334'
protocols: [ 'tcp' ]
comment: 'Added by debops.rspamd Ansible role.'
- name: 'rspamd-fuzzy'
port: '11335'
protocols: [ 'udp' ]
comment: 'Added by debops.rspamd Ansible role.'
# ]]]
# .. envvar:: rspamd__nginx__dependent_servers [[[
#
# Configuration for the :ref:`debops.nginx` role.
rspamd__nginx__dependent_servers:
- name: '{{ rspamd__nginx_fqdns }}'
filename: 'debops.rspamd'
by_role: 'debops.rspamd'
access_policy: '{{ rspamd__nginx_access_policy }}'
webroot_create: False
type: 'proxy'
proxy_pass: 'http://localhost:11334'
# ]]]
# .. envvar:: rspamd__ferm__dependent_rules [[[
#
# Configuration for the :ref:`debops.ferm` role.
rspamd__ferm__dependent_rules:
- type: 'accept'
dport: [ 'rspamd-proxy' ]
protocol: [ 'tcp' ]
saddr: '{{ rspamd__proxy_allow }}'
accept_any: False
weight: '50'
role: 'rspamd'
- type: 'accept'
dport: [ 'rspamd-normal' ]
protocol: [ 'tcp' ]
saddr: '{{ rspamd__normal_allow }}'
accept_any: False
weight: '50'
role: 'rspamd'
- type: 'accept'
dport: [ 'rspamd-controller' ]
protocol: [ 'tcp' ]
saddr: '{{ rspamd__controller_allow }}'
accept_any: False
weight: '50'
role: 'rspamd'
- type: 'accept'
dport: [ 'rspamd-fuzzy' ]
protocol: [ 'udp' ]
saddr: '{{ rspamd__fuzzy_allow }}'
accept_any: False
weight: '50'
role: 'rspamd'
# ]]]
# .. envvar:: rspamd__postfix__dependent_maincf [[[
#
# The :file:`main.cf` configuration for the :ref:`debops.postfix` role.
rspamd__postfix__dependent_maincf:
- name: 'smtpd_milters'
comment: 'Added by the rspamd role'
value:
- name: 'inet:localhost:11332'
weight: -400
state: 'present'
- name: 'non_smtpd_milters'
comment: 'Added by the rspamd role'
value:
- name: 'inet:localhost:11332'
weight: -400
state: 'present'
- name: 'milter_mail_macros'
comment: 'Added by the rspamd role'
value: '{{ "i {auth_type} {auth_authen} {auth_author} "
+ "{client_addr} {client_name} {mail_addr} "
+ "{mail_host} {mail_mailer}" }}'
state: 'present'
- name: 'milter_default_action'
comment: 'Added by the rspamd role'
value: 'accept'
state: 'comment'
- name: 'milter_protocol'
comment: 'Added by the rspamd role'
value: 6
state: 'comment'
# ]]]
# ]]]
# ]]]