-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.yaml
65 lines (65 loc) · 1.74 KB
/
mail.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
- hosts: all
tasks:
- name: init array
set_fact:
ips: []
ports: []
- name: resolve ipv4
set_fact: ips="{{ ips + [ lookup('dig', item + '.', 'qtype=A') ] }}"
loop: "{{ ansible_play_hosts_all }}"
- name: resolve ipv6
set_fact: ips="{{ ips + [ lookup('dig', item + '.', 'qtype=AAAA') ] }}"
loop: "{{ ansible_play_hosts_all }}"
- name: required packages on mailserver
pacman:
name:
- dovecot
- mailman
state: latest
when: "'mail' in group_names"
- name: required packages on relays
pacman:
name:
- exim
state: latest
when: "'mail' not in group_names"
- name: exim is in ssl group
user:
name: exim
groups: ssl
- name: dovecot is in ssl group
user:
name: dovecot
groups: ssl
when: "'mail' in group_names"
- name: chattr -i /etc/mail/exim.conf
file:
path: /etc/mail/exim.conf
attributes: -i
- name: create exim.conf on mailserver
template:
src: exim-main.j2
dest: /etc/mail/exim.conf
when: "'mail' in group_names"
- name: create exim.conf on relays
template:
src: exim-relay.j2
dest: /etc/mail/exim.conf
when: "'mail' not in group_names"
- name: check config
command: exim -C /etc/mail/exim.conf -bV
- name: chattr +i /etc/mail/exim.conf
file:
path: /etc/mail/exim.conf
attributes: +i
- name: enable/restart exim
systemd:
state: restarted
enabled: yes
name: exim
- name: enable/restart dovecot
systemd:
state: restarted
enabled: yes
name: dovecot
when: "'mail' in group_names"