main.yml 3 KB
Newer Older
Hinrikus Wolf's avatar
Hinrikus Wolf committed
1
2
---

3
4
5
6
7
8
9
- name: "include tls config vars (preset: {{ dovecot_tls_configuration }})"
  include_vars:
    file: "tls-{{ dovecot_tls_configuration }}.yml"
  tags:
    - dovecot
    - mail

Hinrikus Wolf's avatar
Hinrikus Wolf committed
10
- name: ensure all required dovecot packages are installed
Lars Beckers's avatar
Lars Beckers committed
11
  apt:
12
13
14
15
16
17
    name:
      - dovecot-core
      - dovecot-imapd
      - dovecot-lmtpd
      - dovecot-managesieved
      - dovecot-sieve
Lars Beckers's avatar
Lars Beckers committed
18
    state: present
Lars Beckers's avatar
Lars Beckers committed
19
  tags:
Hinrikus Wolf's avatar
Hinrikus Wolf committed
20
    - dovecot
Hinrikus Wolf's avatar
Hinrikus Wolf committed
21
    - mail
Hinrikus Wolf's avatar
Hinrikus Wolf committed
22
23

- name: ensure all configs are present
Lars Beckers's avatar
Lars Beckers committed
24
25
26
  template:
    src: "{{ item }}.j2"
    dest: "/etc/dovecot/{{ item }}"
Hinrikus Wolf's avatar
Hinrikus Wolf committed
27
  with_items:
Lars Beckers's avatar
Lars Beckers committed
28
29
30
31
32
33
34
35
36
37
38
39
    - dovecot.conf
    - deny-users
    - conf.d/10-auth.conf
    - conf.d/10-mail.conf
    - conf.d/10-master.conf
    - conf.d/10-ssl.conf
    - conf.d/15-lda.conf
    - conf.d/20-managesieve.conf
    - conf.d/20-imap.conf
    - conf.d/20-lmtp.conf
    - conf.d/90-sieve.conf
    - conf.d/auth-passwdfile.conf.ext
Hinrikus Wolf's avatar
Hinrikus Wolf committed
40
41
42
43
  notify:
    - restart dovecot
  tags:
    - dovecot
Hinrikus Wolf's avatar
Hinrikus Wolf committed
44
45
    - mail

46
47
48
49
50
51
52
53
54
55
56
57
58
59
- name: ensure dh params are available
  copy:
    src: "{{ dovecot_tls_dh_file }}"
    dest: /etc/dovecot/dh.pem
    owner: root
    group: root
    mode: '0644'
  when: dovecot_tls_dh_file is string
  notify:
    - restart dovecot
  tags:
    - dovecot
    - mail

60
- name: ensure there is a folder for global sieve scripts
Lars Beckers's avatar
Lars Beckers committed
61
62
63
64
65
  file:
    dest: /var/lib/dovecot/sieve.d
    state: directory
    owner: dovecot
    group: "{{ dovecot_users_group }}"
Lars Beckers's avatar
Lars Beckers committed
66
    mode: '0755'
67
68
69
70
71
  tags:
    - dovecot
    - mail

- name: ensure the global spam filter and learning sieve script is present
Lars Beckers's avatar
Lars Beckers committed
72
73
74
  template:
    src: "sieve/{{ item }}.j2"
    dest: "/var/lib/dovecot/sieve.d/{{ item }}"
75
    mode: '0640'
Lars Beckers's avatar
Lars Beckers committed
76
77
78
79
    owner: dovecot
    group: "{{ dovecot_users_group }}"
  with_items:
    - filter-spam.sieve
80
81
    - report-spam.sieve
    - report-ham.sieve
Lars Beckers's avatar
Lars Beckers committed
82
  when: dovecot_content_filter
83
  notify:
84
    - compile sieve scripts
85
86
  tags:
    - dovecot
Lars Beckers's avatar
Lars Beckers committed
87
88
89
    - spamassassin
    - mail

90
91
- meta: flush_handlers

Lars Beckers's avatar
Lars Beckers committed
92
# yamllint disable-line rule:line-length
93
94
- name: ensure the global spam filter and learning sieve script have correct permissions
  file:
95
    state: file
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    path: "/var/lib/dovecot/sieve.d/{{ item }}"
    mode: '0640'
    owner: dovecot
    group: "{{ dovecot_users_group }}"
  with_items:
    - filter-spam.svbin
    - report-spam.svbin
    - report-ham.svbin
  when: dovecot_content_filter
  tags:
    - dovecot
    - spamassassin
    - mail

Lars Beckers's avatar
Lars Beckers committed
110
- name: ensure scripts for learning spam are present
111
112
  template:
    src: "{{ item }}.j2"
Lars Beckers's avatar
Lars Beckers committed
113
    dest: "/var/lib/dovecot/sieve.d/{{ item }}"
Lars Beckers's avatar
Lars Beckers committed
114
    mode: '0750'
Lars Beckers's avatar
Lars Beckers committed
115
116
117
118
119
120
121
122
123
    owner: dovecot
    group: "{{ dovecot_users_group }}"
  with_items:
    - sa-learn-ham.sh
    - sa-learn-spam.sh
  when: dovecot_content_filter
  tags:
    - dovecot
    - spamassassin
124
    - mail
Hinrikus Wolf's avatar
Hinrikus Wolf committed
125

Hinrikus Wolf's avatar
Hinrikus Wolf committed
126
- name: ensure dsync config is present
Lars Beckers's avatar
Lars Beckers committed
127
128
129
130
  template:
    src: conf.d/99-dsync.conf.j2
    dest: /etc/dovecot/conf.d/99-dsync.conf
  when: dovecot_dsync
Hinrikus Wolf's avatar
Hinrikus Wolf committed
131
132
133
134
135
136
  notify:
    - restart dovecot
  tags:
    - dovecot
    - mail

Lars Beckers's avatar
Lars Beckers committed
137
138
139
140
- name: ensure dovecot is enabled and running
  service:
    name: dovecot
    state: started
Lars Beckers's avatar
Lars Beckers committed
141
    enabled: true
Lars Beckers's avatar
Lars Beckers committed
142
143
144
  tags:
    - dovecot
    - mail