-
Notifications
You must be signed in to change notification settings - Fork 83
/
main.yml
244 lines (229 loc) · 6.03 KB
/
main.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# tasks file
---
- name: facts | set
ansible.builtin.set_fact:
is_docker_guest: "{{ ansible_virtualization_role | default('host') == 'guest' and ansible_virtualization_type | default('none') == 'docker' }}"
tags:
- configuration
- postfix
- postfix-facts
- name: configure debconf
ansible.builtin.debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
vtype: "{{ item.vtype }}"
with_items: "{{ postfix_debconf_selections }}"
tags:
- configuration
- postfix
- postfix-install
- name: install package
ansible.builtin.apt:
name: "{{ postfix_install }}"
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}"
tags:
- configuration
- postfix
- postfix-install
- name: configure mailname
ansible.builtin.template:
src: "{{ postfix_mailname_file.lstrip('/') }}.j2"
dest: "{{ postfix_mailname_file }}"
owner: root
group: root
mode: '0644'
notify: restart postfix
tags:
- configuration
- postfix
- postfix-mailname
- name: update configuration file
ansible.builtin.template:
src: "{{ postfix_main_cf.lstrip('/') }}.j2"
dest: "{{ postfix_main_cf }}"
owner: root
group: root
mode: '0644'
notify: restart postfix
tags:
- configuration
- postfix
- postfix-configuration
- name: configure sasl username/password
ansible.builtin.template:
src: "{{ postfix_sasl_passwd_file.lstrip('/') }}.j2"
dest: "{{ postfix_sasl_passwd_file }}"
owner: root
group: root
mode: '0600'
when:
- postfix_relayhost | length
- postfix_sasl_auth_enable | bool
no_log: "{{ not ansible_check_mode }}"
notify:
- postmap sasl_passwd
- restart postfix
tags:
- configuration
- postfix
- postfix-sasl-passwd
- name: configure aliases
ansible.builtin.template:
src: "{{ postfix_aliases_file.lstrip('/') }}.j2"
dest: "{{ postfix_aliases_file }}"
owner: root
group: root
mode: '0644'
notify:
- new aliases
- restart postfix
tags:
- configuration
- postfix
- postfix-aliases
- name: check if aliases.db exists
ansible.builtin.stat:
path: "{{ postfix_aliases_file }}.db"
register: _aliasesdb
changed_when: not _aliasesdb.stat.exists
when: postfix_aliases_database_type == 'hash'
notify:
- new aliases
- restart postfix
tags:
- configuration
- postfix
- postfix-aliases
- name: configure virtual aliases
ansible.builtin.lineinfile:
dest: "{{ postfix_virtual_aliases_file }}"
regexp: '^{{ item.virtual | regex_escape }}\s.*'
line: '{{ item.virtual }} {{ item.alias }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_virtual_aliases }}"
notify:
- new virtual aliases
- restart postfix
tags:
- configuration
- postfix
- postfix-virtual-aliases
- name: configure sender canonical maps
ansible.builtin.lineinfile:
dest: "{{ postfix_sender_canonical_maps_file }}"
regexp: '^{{ item.sender | regex_escape }}\s.*'
line: '{{ item.sender }} {{ item.rewrite }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_sender_canonical_maps }}"
notify:
- postmap sender_canonical_maps
- restart postfix
tags:
- configuration
- postfix
- postfix-sender-canonical-maps
- name: configure recipient canonical maps
ansible.builtin.lineinfile:
dest: "{{ postfix_recipient_canonical_maps_file }}"
regexp: '^{{ item.recipient | regex_escape }}\s.*'
line: '{{ item.recipient }} {{ item.rewrite }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_recipient_canonical_maps }}"
notify:
- postmap recipient_canonical_maps
- restart postfix
tags:
- configuration
- postfix
- postfix-recipient-canonical-maps
- name: configure transport maps
ansible.builtin.lineinfile:
dest: "{{ postfix_transport_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_transport_maps }}"
notify:
- postmap transport_maps
- restart postfix
tags:
- configuration
- postfix
- postfix-transport-maps
- name: configure sender dependent relayhost maps
ansible.builtin.lineinfile:
dest: "{{ postfix_sender_dependent_relayhost_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_sender_dependent_relayhost_maps }}"
notify:
- postmap sender_dependent_relayhost_maps
- restart postfix
tags:
- configuration
- postfix
- postfix-sender-dependent-relayhost-maps
- name: configure generic table
ansible.builtin.lineinfile:
dest: "{{ postfix_smtp_generic_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
owner: root
group: root
mode: '0644'
create: true
state: present
with_items: "{{ postfix_smtp_generic_maps }}"
notify:
- postmap generic
- restart postfix
tags:
- configuration
- postfix
- postfix-generic-table
- name: configure header checks
ansible.builtin.template:
src: "{{ postfix_header_checks_file.lstrip('/') }}.j2"
dest: "{{ postfix_header_checks_file }}"
owner: root
group: root
mode: '0644'
notify:
- restart postfix
tags:
- configuration
- postfix
- postfix-header-checks-table
- name: start and enable service
ansible.builtin.service:
name: postfix
state: "{{ service_default_state | default('started') }}"
enabled: "{{ service_default_enabled | default(true) | bool }}"
tags:
- configuration
- postfix
- postfix-start-enable-service