|
@@ -1,6 +1,12 @@
|
|
1
|
+---
|
|
2
|
+# Installs and configures the Dovecot IMAP/POP3 server.
|
|
3
|
+
|
1
|
4
|
- name: Install Dovecot and related packages
|
2
|
|
- apt: pkg={{ item }} update_cache=yes state=present
|
3
|
|
- with_items:
|
|
5
|
+ apt:
|
|
6
|
+ name: "{{ packages }}"
|
|
7
|
+ state: present
|
|
8
|
+ vars:
|
|
9
|
+ packages:
|
4
|
10
|
- dovecot-core
|
5
|
11
|
- dovecot-imapd
|
6
|
12
|
- dovecot-lmtpd
|
|
@@ -11,38 +17,65 @@
|
11
|
17
|
tags:
|
12
|
18
|
- dependencies
|
13
|
19
|
|
14
|
|
-- name: Install Postgres for Dovecot
|
15
|
|
- apt: pkg=postgresql state=present
|
16
|
|
- tags:
|
17
|
|
- - dependencies
|
18
|
|
-
|
19
|
20
|
- name: Create vmail group
|
20
|
|
- group: name=vmail state=present gid=5000
|
|
21
|
+ group:
|
|
22
|
+ name=vmail
|
|
23
|
+ state=present
|
|
24
|
+ gid=5000
|
21
|
25
|
|
22
|
26
|
- name: Create vmail user
|
23
|
|
- user: name=vmail group=vmail state=present uid=5000 home=/data shell=/usr/sbin/nologin
|
|
27
|
+ user:
|
|
28
|
+ name=vmail
|
|
29
|
+ group=vmail
|
|
30
|
+ state=present
|
|
31
|
+ uid=5000
|
|
32
|
+ home=/data
|
|
33
|
+ shell=/usr/sbin/nologin
|
24
|
34
|
|
25
|
35
|
- name: Ensure mail domain directories are in place
|
26
|
|
- file: state=directory path=/data/{{ item.name }} owner=vmail group=dovecot mode=0770
|
|
36
|
+ file:
|
|
37
|
+ state=directory
|
|
38
|
+ path=/data/{{ item.name }}
|
|
39
|
+ owner=vmail
|
|
40
|
+ group=dovecot
|
|
41
|
+ mode=0770
|
27
|
42
|
with_items: '{{ virtual_domains }}'
|
28
|
43
|
|
29
|
44
|
- name: Ensure mail directories are in place
|
30
|
|
- file: state=directory path=/data/{{ item.domain }}/{{ item.account }} owner=vmail group=dovecot
|
|
45
|
+ file:
|
|
46
|
+ state=directory
|
|
47
|
+ path=/data/{{ item.domain }}/{{ item.account }}
|
|
48
|
+ owner=vmail
|
|
49
|
+ group=dovecot
|
31
|
50
|
with_items: '{{ mail_virtual_users }}'
|
32
|
51
|
|
33
|
52
|
- name: Copy dovecot.conf into place
|
34
|
|
- copy: src=etc_dovecot_dovecot.conf dest=/etc/dovecot/dovecot.conf
|
|
53
|
+ copy:
|
|
54
|
+ src=etc_dovecot_dovecot.conf
|
|
55
|
+ dest=/etc/dovecot/dovecot.conf
|
35
|
56
|
|
36
|
57
|
- name: Create before.d sieve scripts directory
|
37
|
|
- file: path=/etc/dovecot/sieve/before.d state=directory owner=vmail group=dovecot recurse=yes mode=0770
|
|
58
|
+ file:
|
|
59
|
+ path=/etc/dovecot/sieve/before.d
|
|
60
|
+ state=directory
|
|
61
|
+ owner=vmail
|
|
62
|
+ group=dovecot
|
|
63
|
+ recurse=yes
|
|
64
|
+ mode=0770
|
38
|
65
|
notify: restart dovecot
|
39
|
66
|
|
40
|
67
|
- name: Configure sieve script moving spam into Junk folder
|
41
|
|
- copy: src=etc_dovecot_sieve_before.d_no-spam.sieve dest=/etc/dovecot/sieve/before.d/no-spam.sieve owner=vmail group=dovecot
|
|
68
|
+ copy:
|
|
69
|
+ src=etc_dovecot_sieve_before.d_no-spam.sieve
|
|
70
|
+ dest=/etc/dovecot/sieve/before.d/no-spam.sieve
|
|
71
|
+ owner=vmail
|
|
72
|
+ group=dovecot
|
42
|
73
|
notify: restart dovecot
|
43
|
74
|
|
44
|
75
|
- name: Copy additional Dovecot configuration files in place
|
45
|
|
- copy: src=etc_dovecot_conf.d_{{ item }} dest=/etc/dovecot/conf.d/{{ item }}
|
|
76
|
+ copy:
|
|
77
|
+ src=etc_dovecot_conf.d_{{ item }}
|
|
78
|
+ dest=/etc/dovecot/conf.d/{{ item }}
|
46
|
79
|
with_items:
|
47
|
80
|
- 10-auth.conf
|
48
|
81
|
- 10-mail.conf
|
|
@@ -53,25 +86,30 @@
|
53
|
86
|
- auth-sql.conf.ext
|
54
|
87
|
notify: restart dovecot
|
55
|
88
|
|
56
|
|
-- name: Template 10-ssl.conf
|
57
|
|
- template: src=etc_dovecot_conf.d_10-ssl.conf.j2 dest=/etc/dovecot/conf.d/10-ssl.conf
|
58
|
|
- notify: restart dovecot
|
59
|
|
-
|
60
|
|
-- name: Template 15-lda.conf
|
61
|
|
- template: src=etc_dovecot_conf.d_15-lda.conf.j2 dest=/etc/dovecot/conf.d/15-lda.conf
|
62
|
|
- notify: restart dovecot
|
63
|
|
-
|
64
|
|
-- name: Template 20-imap.conf
|
65
|
|
- template: src=etc_dovecot_conf.d_20-imap.conf.j2 dest=/etc/dovecot/conf.d/20-imap.conf
|
|
89
|
+- name: Template additional Dovecot configuration files
|
|
90
|
+ template:
|
|
91
|
+ src=etc_dovecot_conf.d_{{ item }}.j2
|
|
92
|
+ dest=/etc/dovecot/conf.d/{{ item }}
|
|
93
|
+ with_items:
|
|
94
|
+ - 10-ssl.conf
|
|
95
|
+ - 15-lda.conf
|
|
96
|
+ - 20-imap.conf
|
66
|
97
|
notify: restart dovecot
|
67
|
98
|
|
68
|
99
|
- name: Template dovecot-sql.conf.ext
|
69
|
|
- template: src=etc_dovecot_dovecot-sql.conf.ext.j2 dest=/etc/dovecot/dovecot-sql.conf.ext
|
|
100
|
+ template:
|
|
101
|
+ src=etc_dovecot_dovecot-sql.conf.ext.j2
|
|
102
|
+ dest=/etc/dovecot/dovecot-sql.conf.ext
|
70
|
103
|
notify: restart dovecot
|
71
|
104
|
|
72
|
105
|
- name: Ensure correct permissions on Dovecot config directory
|
73
|
|
- file: state=directory path=/etc/dovecot
|
74
|
|
- group=dovecot owner=vmail mode=0770 recurse=yes
|
|
106
|
+ file:
|
|
107
|
+ state=directory
|
|
108
|
+ path=/etc/dovecot
|
|
109
|
+ group=dovecot
|
|
110
|
+ owner=vmail
|
|
111
|
+ mode=0770
|
|
112
|
+ recurse=yes
|
75
|
113
|
notify: restart dovecot
|
76
|
114
|
|
77
|
115
|
- name: Set firewall rules for dovecot
|