-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yaml
119 lines (99 loc) · 2.98 KB
/
playbook.yaml
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
117
118
119
- name: Get PIs setup with SMTP relay capabilitys
hosts: pis
become: true
tasks:
- name: install smtp packages
ansible.builtin.apt:
pkg:
- libsasl2-modules
- postfix
state: present
- name: set postconf relayhost
postconf:
name: relayhost
value: "[smtp.sendgrid.net]:587"
state: present
- name: set postconf inet_protocols
postconf:
name: inet_protocols
value: ipv4
state: present
- name: set postconf smtp_tls_security_level
postconf:
name: smtp_tls_security_level
value: encrypt
state: present
- name: set postconf header_size_limit
postconf:
name: header_size_limit
value: 4096000
state: present
- name: set postconf smtp_use_tls
postconf:
name: smtp_use_tls
value: "yes"
state: present
- name: set postconf smtp_enforce_tls
postconf:
name: smtp_enforce_tls
value: "yes"
state: present
- name: set postconf smtp_sasl_auth_enable
postconf:
name: smtp_sasl_auth_enable
value: "yes"
state: present
- name: set postconf smtp_sasl_security_options
postconf:
name: smtp_sasl_security_options
value: noanonymous
state: present
- name: set postconf smtp_sasl_tls_security_options
postconf:
name: smtp_sasl_tls_security_options
value: noanonymous
state: present
- name: set postconf password_maps
postconf:
name: smtp_sasl_password_maps
value: hash:/etc/postfix/sasl_passwd
state: present
- name: set postconf sender_canonical_maps
postconf:
name: sender_canonical_maps
value: hash:/etc/postfix/sender_canonical
state: absent
- name: set postconf smtp_generic_maps
postconf:
name: smtp_generic_maps
value: hash:/etc/postfix/generic
state: absent
- name: Creating password file
copy:
dest: "/etc/postfix/sasl_passwd"
content:
smtp.sendgrid.net apikey:{{ sendgird_api_key }}
- name: Change file ownership, group and permissions for /etc/postfix/sasl_passwd
ansible.builtin.file:
path: /etc/postfix/sasl_passwd
owner: root
group: root
mode: '0600'
- name: do postmap postfix
ansible.builtin.shell: postmap /etc/postfix/sasl_passwd
- name: Creating alias file
copy:
dest: "/etc/postfix/generic"
content: ""
- name: Template a file to /etc/aliases
ansible.builtin.template:
src: ./templates/aliases.j2
dest: /etc/aliases
- name: do postmap generic
ansible.builtin.shell: newaliases
- name: do postmap generic
ansible.builtin.shell: postmap /etc/postfix/generic
- name: Restart service postfix, in all cases
ansible.builtin.service:
name: postfix
state: restarted