-
Notifications
You must be signed in to change notification settings - Fork 0
/
email.yml
116 lines (95 loc) · 3.29 KB
/
email.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
---
- hosts: [ server ]
remote_user: "{{ remote_user }}"
become: yes
roles:
- geerlingguy.repo-epel
- role: thefinn93.letsencrypt
letsencrypt_email: "letsencrypt@{{ mail_domain }}"
letsencrypt_cert_domains:
- "{{ fully_qualified_domain }}"
- "{{ wallabag_domain }}"
- "foobar.landau.fi"
letsencrypt_renewal_command_args: '--renew-hook "systemctl restart nginx postfix dovecot"'
tasks:
- name: Install email server programs
yum: pkg={{item}} state=present
with_items:
- postfix
- dovecot
- dovecot-pigeonhole
- opendkim
- mailx
- spamassassin
- name: Create postfix dhparam
command: openssl dhparam -out /etc/postfix/dhparam.pem 2048
args:
creates: /etc/postfix/dhparam.pem
- name: Create postfix mail recipient user
user:
name: "{{ mail_recipient_user }}"
shell: /sbin/nologin
password: "{{ mail_recipient_passwd }}"
# According to https://www.rosehosting.com/blog/how-to-install-and-integrate-spamassassin-with-postfix-on-a-centos-6-vps/
- name: Create spamassassin group
group: name=spamfilter
- name: Create spamassassin user
user:
name: spamfilter
group: spamfilter
home: /usr/local/spamassassin
shell: /sbin/nologin
password: "!"
- name: Set spamassassin home dir owner
file: path=/usr/local/spamassassin owner=spamfilter
- name: Install spamd conf
copy: src=spamassassin-sysconfig dest=/etc/sysconfig/spamassassin
notify:
- restart spamassassin
- service: name={{item}} state=started enabled=yes
with_items: [ postfix, dovecot, spamassassin ]
- name: Generate opendkim key
command: opendkim-genkey -r -s mail -d {{ mail_domain }}
args:
chdir: /etc/opendkim/keys
creates: /etc/opendkim/keys/mail.private
notify:
- restart opendkim
- name: Fix opendkim key permissions
file: path=/etc/opendkim/keys/{{item}} owner=opendkim group=opendkim
with_items: [ mail.private, mail.txt ]
- name: Install opendkim conf
template: src=opendkim.conf dest=/etc/opendkim.conf
notify:
- restart opendkim
- service: name={{item}} state=started enabled=yes
with_items: [ opendkim ]
- name: Install dovecot conf main file
template: src=dovecot.conf dest=/etc/dovecot/dovecot.conf
notify:
- restart dovecot
- name: Install dovecot rest conf files
template: src=dovecot.conf.d/{{item}} dest=/etc/dovecot/conf.d/{{item}}
with_items: [ 10-mail.conf, 10-master.conf, 10-ssl.conf, 15-lda.conf, 90-sieve.conf ]
notify:
- restart dovecot
- name: Install postfix conf files
template: src={{item}} dest=/etc/postfix/{{item}}
with_items:
- main.cf
- master.cf
- aliases
notify:
- rebuild aliases
- restart postfix
handlers:
- name: rebuild aliases
command: newaliases
- name: restart postfix
service: name=postfix state=restarted
- name: restart opendkim
service: name=opendkim state=restarted
- name: restart dovecot
service: name=dovecot state=restarted
- name: restart spamassassin
service: name=spamassassin state=restarted