forked from migonzalvar/bootstrapping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postfix.yml
68 lines (68 loc) · 2.08 KB
/
postfix.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
---
- hosts: localhost
connection: local
become: yes
vars_files:
- vault.yml
- vars.yml
tasks:
- name: postfix installed
dnf:
name: '{{ item }}'
state: present
with_items:
- postfix
- libselinux-python
- name: add aliases
lineinfile:
dest: /etc/aliases
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
with_items:
- regexp: '^root:'
line: "root:\t\tmigonzalvar"
- regexp: '^migonzalvar:'
line: "migonzalvar:\[email protected]"
register: add_alias
- name: updated aliases database
command: /usr/bin/newaliases
when: add_alias|changed
- name: configured generic
lineinfile:
dest: /etc/postfix/generic
line: '{{ item }}'
with_items:
- "migonzalvar\t\[email protected]"
register: configured_generic
- name: updated generic database
command: /usr/sbin/postmap /etc/postfix/generic
when: configured_generic|changed
- name: configured sasl_passwd
lineinfile:
dest: /etc/postfix/sasl_passwd
line: '{{ item }}'
with_items:
- '[dns73112.phdns12.es]:587 [email protected]:{{ mail_password }}'
register: configured_sasl_passwd
- name: updated sasl_passwd database
command: /usr/sbin/postmap /etc/postfix/generic
when: configured_sasl_passwd|changed
- name: configured main.cf
lineinfile:
dest: /etc/postfix/main.cf
line: '{{ item }}'
with_items:
- relayhost = [dns73112.phdns12.es]:587
- smtp_use_tls = yes
- smtp_sasl_auth_enable = yes
- smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
- smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
- smtp_sasl_security_options = noanonymous
- smtp_sasl_tls_security_options = noanonymous
- smtp_generic_maps = hash:/etc/postfix/generic
register: configured_main_cf
- name: reloaded postfix
service:
name: postfix
state: reloaded
when: configured_main_cf|changed