Преглед на файлове

Cleanup postfix task. Move password hashing into top level config file.

Thomas Buck преди 5 години
родител
ревизия
9411373c5b

+ 1
- 1
group_vars/sovereign Целия файл

@@ -20,7 +20,7 @@ virtual_domains:
20 20
 mail_virtual_users:
21 21
   - account: "{{ main_user_name }}"
22 22
     domain: "{{ domain }}"
23
-    password: TODO
23
+    password: "{{ 'changeme' | doveadm_pw_hash }}"
24 24
     domain_pk_id: 1
25 25
 mail_virtual_aliases:
26 26
   - source: "root@{{ domain }}"

+ 4
- 2
roles/mailserver/defaults/main.yml Целия файл

@@ -14,8 +14,10 @@ mail_server_hostname: "mail.{{ domain }}"
14 14
 mail_server_autoconfig_hostname: "autoconfig.{{ domain }}"
15 15
 mail_header_privacy: 1
16 16
 
17
-# virtual domains
18
-mail_virtual_domains: []
17
+friendly_networks:
18
+  - ""
19
+
20
+virtual_domains: []
19 21
 mail_virtual_users: []
20 22
 mail_virtual_aliases: []
21 23
 

+ 54
- 10
roles/mailserver/tasks/postfix.yml Целия файл

@@ -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

+ 0
- 5
roles/mailserver/templates/etc_postfix_mysql-virtual-alias-maps.cf.j2 Целия файл

@@ -1,5 +0,0 @@
1
-user = {{ mail_db_username }}
2
-password = {{ mail_db_password }}
3
-hosts = 127.0.0.1
4
-dbname = {{ mail_db_database }}
5
-query = SELECT destination FROM virtual_aliases WHERE source='%s'

+ 0
- 5
roles/mailserver/templates/etc_postfix_mysql-virtual-mailbox-domains.cf.j2 Целия файл

@@ -1,5 +0,0 @@
1
-user = {{ mail_db_username }}
2
-password = {{ mail_db_password }}
3
-hosts = 127.0.0.1
4
-dbname = {{ mail_db_database }}
5
-query = SELECT 1 FROM virtual_domains WHERE name='%s'

+ 0
- 5
roles/mailserver/templates/etc_postfix_mysql-virtual-mailbox-maps.cf.j2 Целия файл

@@ -1,5 +0,0 @@
1
-user = {{ mail_db_username }}
2
-password = {{ mail_db_password }}
3
-hosts = 127.0.0.1
4
-dbname = {{ mail_db_database }}
5
-query = SELECT 1 FROM virtual_users WHERE email='%s'

+ 1
- 1
roles/mailserver/templates/mailserver.sql.j2 Целия файл

@@ -44,7 +44,7 @@ INSERT INTO "virtual_domains" ("id", "name")
44 44
 INSERT INTO "virtual_users"  ("domain_id", "password" , "email")
45 45
 	VALUES (
46 46
 		'{{ virtual_user.domain_pk_id }}',
47
-		'{{ virtual_user.password | doveadm_pw_hash }}',
47
+		'{{ virtual_user.password }}',
48 48
 		'{{ virtual_user.account }}@{{ virtual_user.domain }}'
49 49
 	);
50 50
 {% endfor %}

Loading…
Отказ
Запис