Skip to content

Commit 7721159

Browse files
committed
postfix: first impletentation of spam and virus filter
1 parent 0fb9b2c commit 7721159

File tree

4 files changed

+66
-36
lines changed

4 files changed

+66
-36
lines changed

roles/dovecot/tasks/main.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
- dovecot-ldap
77
- dovecot-imapd
88
- rsyslog
9-
# - dovecot-lmtpd
10-
# - amavisd-new
11-
# - postgrey #TODO
12-
# - spamassassin
13-
# - clamav-daemon
149

1510
- lineinfile: dest=/etc/postfix/main.cf line="virtual_transport = dovecot" state=present
1611
notify: restart postfix
@@ -88,34 +83,3 @@
8883

8984
- template: src=dovecot-ldap.conf.ext.j2 dest=/etc/dovecot/dovecot-ldap.conf.ext
9085
notify: restart dovecot
91-
92-
#- lineinfile: dest=/etc/postfix/main.cf line="content_filter=smtp-amavis:[127.0.0.1]:10024" state=present
93-
# notify: restart_postfix
94-
95-
#- blockinfile: |
96-
# dest=/etc/postfix/master.cf
97-
# content=" smtp-amavis unix - - n - 2 smtp
98-
# -o smtp_data_done_timeout=1200
99-
# -o smtp_send_xforward_command=yes
100-
# -o disable_dns_lookups=yes
101-
# -o max_use=20
102-
#
103-
# 127.0.0.1:10025 inet n - n - - smtpd
104-
# -o content_filter=
105-
# -o smtpd_delay_reject=no
106-
# -o smtpd_client_restrictions=permit_mynetworks,reject
107-
# -o smtpd_helo_restrictions=
108-
# -o smtpd_sender_restrictions=
109-
# -o smtpd_recipient_restrictions=permit_mynetworks,reject
110-
# -o smtpd_data_restrictions=reject_unauth_pipelining
111-
# -o smtpd_end_of_data_restrictions=
112-
# -o smtpd_restriction_classes=
113-
# -o mynetworks=127.0.0.0/8
114-
# -o smtpd_error_sleep_time=0
115-
# -o smtpd_soft_error_limit=1001
116-
# -o smtpd_hard_error_limit=1000
117-
# -o smtpd_client_connection_count_limit=0
118-
# -o smtpd_client_connection_rate_limit=0
119-
# -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
120-
# -o local_header_rewrite_clients="
121-
# notify: restart_postfix

roles/postfix/handlers/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,12 @@
22
- include: service.yaml
33
vars:
44
service_name: postfix
5+
6+
7+
- include: service.yaml
8+
vars:
9+
service_name: clamav-daemon
10+
11+
- include: service.yaml
12+
vars:
13+
service_name: amavisd-milter

roles/postfix/tasks/antispam.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
- include: service.yaml
2+
vars:
3+
service_name: clamav-daemon
4+
service_packages:
5+
- clamav-daemon
6+
install_recommends: yes
7+
8+
- include: service.yaml
9+
vars:
10+
service_name: amavisd-milter
11+
service_packages:
12+
- amavisd-milter
13+
- spamassassin
14+
install_recommends: yes
15+
16+
- name: disable spamassassin at boot
17+
service: name="spamassassin" enabled=no
18+
19+
# TODO spam, discard spam instead of bouncing it
20+
# /etc/amavis/conf.d/
21+
# $final_spam_destiny = D_DISCARD;
22+
23+
- name: configure amavisd-milter socket
24+
blockinfile:
25+
dest: '/etc/default/amavisd-milter'
26+
block: |
27+
MILTERSOCKET=inet:60001@127.0.0.1
28+
notify: restart amavisd-milter
29+
30+
- name: add amavis milter for smtp to postfix
31+
lineinfile:
32+
dest: '/etc/postfix/main.cf'
33+
line: 'smtpd_milters=inet:127.0.0.1:60001'
34+
regexp: '^smtpd_milters='
35+
notify: restart postfix
36+
37+
- name: add amavis milter for non smtp to postfix
38+
lineinfile:
39+
dest: '/etc/postfix/main.cf'
40+
line: 'non_smtpd_milters=inet:127.0.0.1:60001'
41+
regexp: '^non_smtpd_milters='
42+
notify: restart postfix
43+
44+
- include: service.yaml
45+
vars:
46+
service_name: postgrey
47+
service_packages:
48+
- postgrey
49+
50+
- name: add postgrey to postfix
51+
lineinfile:
52+
dest: '/etc/postfix/main.cf'
53+
line: 'smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:10023'
54+
notify: restart postfix

roles/postfix/tasks/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@
7171
- name: add lists.lilik.it relay
7272
lineinfile: dest=/etc/postfix/main.cf line="relay_domains = lists.lilik.it" regexp='relay_domains =' state=present
7373
notify: restart postfix
74+
75+
- name: install antivirus and anti spam services
76+
include: antispam.yaml

0 commit comments

Comments
 (0)