|
@@ -1,6 +1,12 @@
|
|
1
|
+---
|
|
2
|
+# Installs and configures the Postfix SMTP server.
|
|
3
|
+
|
1
|
4
|
- name: Install Postfix and related packages
|
2
|
|
- apt: pkg={{ item }} state=present
|
3
|
|
- with_items:
|
|
5
|
+ apt:
|
|
6
|
+ name: "{{ packages }}"
|
|
7
|
+ state: present
|
|
8
|
+ vars:
|
|
9
|
+ packages:
|
4
|
10
|
- libsasl2-modules
|
5
|
11
|
- postfix
|
6
|
12
|
- postfix-pcre
|
|
@@ -12,35 +18,73 @@
|
12
|
18
|
- dependencies
|
13
|
19
|
|
14
|
20
|
- name: Create database user for mail server
|
15
|
|
- postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_username }} password="{{ mail_db_password }}" encrypted=yes state=present
|
|
21
|
+ postgresql_user:
|
|
22
|
+ login_host=localhost
|
|
23
|
+ login_user={{ db_admin_username }}
|
|
24
|
+ login_password="{{ db_admin_password }}"
|
|
25
|
+ name={{ mail_db_username }}
|
|
26
|
+ password="{{ mail_db_password }}"
|
|
27
|
+ encrypted=yes
|
|
28
|
+ state=present
|
16
|
29
|
notify: import sql postfix
|
17
|
30
|
|
18
|
31
|
- name: Create database for mail server
|
19
|
|
- postgresql_db: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_database }} state=present owner={{ mail_db_username }}
|
|
32
|
+ postgresql_db:
|
|
33
|
+ login_host=localhost
|
|
34
|
+ login_user={{ db_admin_username }}
|
|
35
|
+ login_password="{{ db_admin_password }}"
|
|
36
|
+ name={{ mail_db_database }}
|
|
37
|
+ state=present
|
|
38
|
+ owner={{ mail_db_username }}
|
20
|
39
|
notify: import sql postfix
|
21
|
40
|
|
22
|
41
|
- name: Copy import.sql
|
23
|
|
- template: src=mailserver.sql.j2 dest=/etc/postfix/import.sql owner=root group=root mode=0600
|
|
42
|
+ template:
|
|
43
|
+ src=mailserver.sql.j2
|
|
44
|
+ dest=/etc/postfix/import.sql
|
|
45
|
+ owner=root
|
|
46
|
+ group=root
|
|
47
|
+ mode=0600
|
24
|
48
|
notify: import sql postfix
|
25
|
49
|
|
26
|
50
|
- name: Create postfix maps directory
|
27
|
|
- file: path=/etc/postfix/maps state=directory owner=root group=root
|
|
51
|
+ file:
|
|
52
|
+ path=/etc/postfix/maps
|
|
53
|
+ state=directory
|
|
54
|
+ owner=root
|
|
55
|
+ group=root
|
28
|
56
|
when: mail_header_privacy == 1
|
29
|
57
|
|
30
|
58
|
- name: Copy smtp_header_checks.pcre
|
31
|
|
- copy: src=etc_postfix_maps_smtp_header_checks.pcre dest=/etc/postfix/maps/smtp_header_checks.pcre owner=root group=root
|
|
59
|
+ copy:
|
|
60
|
+ src=etc_postfix_maps_smtp_header_checks.pcre
|
|
61
|
+ dest=/etc/postfix/maps/smtp_header_checks.pcre
|
|
62
|
+ owner=root
|
|
63
|
+ group=root
|
32
|
64
|
when: mail_header_privacy == 1
|
33
|
65
|
|
34
|
66
|
- name: Copy main.cf
|
35
|
|
- template: src=etc_postfix_main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root
|
|
67
|
+ template:
|
|
68
|
+ src=etc_postfix_main.cf.j2
|
|
69
|
+ dest=/etc/postfix/main.cf
|
|
70
|
+ owner=root
|
|
71
|
+ group=root
|
36
|
72
|
notify: restart postfix
|
37
|
73
|
|
38
|
74
|
- name: Copy master.cf
|
39
|
|
- copy: src=etc_postfix_master.cf dest=/etc/postfix/master.cf owner=root group=root
|
|
75
|
+ copy:
|
|
76
|
+ src=etc_postfix_master.cf
|
|
77
|
+ dest=/etc/postfix/master.cf
|
|
78
|
+ owner=root
|
|
79
|
+ group=root
|
40
|
80
|
notify: restart postfix
|
41
|
81
|
|
42
|
82
|
- name: Copy additional postfix configuration files
|
43
|
|
- template: src=etc_postfix_{{ item }}.j2 dest=/etc/postfix/{{ item }} owner=root group=root
|
|
83
|
+ template:
|
|
84
|
+ src=etc_postfix_{{ item }}.j2
|
|
85
|
+ dest=/etc/postfix/{{ item }}
|
|
86
|
+ owner=root
|
|
87
|
+ group=root
|
44
|
88
|
with_items:
|
45
|
89
|
- pgsql-virtual-alias-maps.cf
|
46
|
90
|
- pgsql-virtual-mailbox-domains.cf
|