-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathinit.pp
More file actions
255 lines (241 loc) · 8.61 KB
/
init.pp
File metadata and controls
255 lines (241 loc) · 8.61 KB
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
245
246
247
248
249
250
251
252
253
254
255
#
# == Class: postfix
#
# This class provides a basic setup of postfix with local and remote
# delivery and an SMTP server listening on the loopback interface.
#
# === Parameters
#
# [*alias_maps*] - (string)
#
# [*configs*] - (hash)
#
# [*hashes*] - (hash) A hash of postfix::hash resources
#
# [*transports*] - (hash) A hash of postfix::transport resources
#
# [*virtuals*] - (hash) A hash of postfix::virtual resources
#
# [*conffiles*] - (hash) A hash of postfix::conffile resources
#
# [*maps*] - (hash) A hash of postfix::map resources
#
# [*amavis_procs*] - (integer) Number of amavis scanners to spawn
#
# [*inet_interfaces*] - (string)
#
# [*inet_protocols*] - (string)
#
# [*ldap*] - (boolean) Whether to use LDAP
#
# [*ldap_base*] - (string)
#
# [*ldap_host*] - (string)
#
# [*ldap_bind_pw*] - (string)
#
# [*ldap_options*] - (string)
#
# [*mail_user*] - (string) The mail user
#
# [*mailman*] - (boolean)
#
# [*maincf_source*] - (string)
#
# [*manage_conffiles*] - (boolean) Whether config files are to be replaced
#
# [*manage_mailname*] - (boolean) Whether to manage /etc/mailname.
#
# [*manage_mailx*] - (boolean) Whether to manage mailx package.
#
# [*masquerade_classes*] - (array)
#
# [*masquerade_domains*] - (array)
#
# [*masquerade_exceptions*] - (array)
#
# [*mastercf_source*] - (string)
#
# [*mastercf_content*] - (string)
#
# [*mastercf_template*] - (string)
#
# [*master_smtp*] - (string)
#
# [*master_smtps*] - (string)
#
# [*master_submission*] - (string)
#
# [*master_entries*] - (array of strings)
#
# [*master_bounce_command*] - (string)
#
# [*master_defer_command*] - (string)
#
# [*mta*] - (boolean) Configure postfix minimally, as a simple MTA
#
# [*mydestination*] - (string)
#
# [*mynetworks*] - (string)
#
# [*myorigin*] - (string)
#
# [*manage_aliases*] - (boolean) Manage /etc/aliases file
#
# [*relayhost*] - (string)
#
# [*root_mail_recipient*] - (string)
#
# [*chroot*] - (undef/boolean) Whether postfix should be run in a chroot
#
# [*satellite*] - (boolean) Whether to use as a satellite
# (implies MTA)
#
# [*smtp_listen*] - (string) The SMTP listen interface
#
# [*use_amavisd*] - (boolean) Whether to setup for Amavis
#
# [*use_dovecot_lda*] - (boolean) Whether to setup for Dovecot LDA
#
# [*use_schleuder*] - (2/boolean) Whether to setup for Schleuder
# (2 -> Schleuder 2, 3 or true -> Schleuder 3)
#
# [*use_sympa*] - (boolean) Whether to setup for Sympa
#
# [*postfix_ensure*] - (string) The ensure value of the postfix package
#
# [*mailx_ensure*] - (string) The ensure value of the mailx package
#
# === Examples
#
# class { 'postfix':
# smtp_listen => '192.168.1.10',
# }
#
class postfix (
Stdlib::Absolutepath $confdir = '/etc/postfix',
String $root_group = 'root',
String $alias_maps = 'hash:/etc/aliases',
Hash $configs = {},
Hash $hashes = {},
Hash $transports = {},
Hash $virtuals = {},
Hash $conffiles = {},
Hash $maps = {},
Integer $amavis_procs = 2,
String $inet_interfaces = 'all',
String $inet_protocols = 'all',
Boolean $ldap = false,
Optional[String] $ldap_base = undef,
Optional[String] $ldap_host = undef,
Optional[String] $ldap_bind_pw = undef,
Optional[Variant[String,Array[String]]] $ldap_options = undef,
String $mail_user = 'vmail', # postfix_mail_user
Boolean $mailman = false,
String $maincf_source = "puppet:///modules/${module_name}/main.cf",
Boolean $manage_conffiles = true,
Boolean $manage_mailname = true,
Boolean $manage_mailx = true,
Optional[Array[String[1]]] $masquerade_classes = undef,
Optional[Array[String[1]]] $masquerade_domains = undef,
Optional[Array[String[1]]] $masquerade_exceptions = undef,
Optional[String] $mastercf_source = undef,
Optional[String] $mastercf_content = undef,
Optional[String] $mastercf_template = undef,
Optional[String] $master_smtp = undef, # postfix_master_smtp
Optional[String] $master_smtps = undef, # postfix_master_smtps
Optional[String] $master_submission = undef, # postfix_master_submission
Array[String] $master_entries = [], # postfix_master_entries
String $master_bounce_command = 'bounce',
String $master_defer_command = 'bounce',
Boolean $mta = false,
String $mydestination = '$myorigin', # postfix_mydestination
String $mynetworks = '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128', # postfix_mynetworks
String $myorigin = $facts['networking']['fqdn'],
Boolean $manage_aliases = true, # /etc/aliases
Optional[String] $relayhost = undef, # postfix_relayhost
Boolean $manage_root_alias = true,
Variant[Array[String], String] $root_mail_recipient = 'nobody', # root_mail_recipient
Optional[Boolean] $chroot = undef,
Boolean $satellite = false,
Variant[Array[String[1]], String[1]] $smtp_listen = '127.0.0.1', # postfix_smtp_listen
Boolean $use_amavisd = false, # postfix_use_amavisd
Boolean $use_dovecot_lda = false, # postfix_use_dovecot_lda
Variant[Integer[2, 3], Boolean] $use_schleuder = false, # postfix_use_schleuder
Boolean $use_sympa = false, # postfix_use_sympa
String $postfix_ensure = 'present',
String $mailx_ensure = 'present',
String $service_ensure = 'running',
Boolean $service_enabled = true,
) inherits postfix::params {
if (
($mastercf_source and $mastercf_content) or
($mastercf_source and $mastercf_template) or
($mastercf_content and $mastercf_template) or
($mastercf_source and $mastercf_content and $mastercf_template)
) {
fail('mastercf_source, mastercf_content and mastercf_template are mutually exclusive')
}
$_smtp_listen = $mailman ? {
true => '0.0.0.0',
default => $smtp_listen,
}
$all_alias_maps = $ldap ? {
false => $alias_maps,
true => "${alias_maps}, ldap:${confdir}/ldap-aliases.cf",
}
$configs.each |$key, $value| {
postfix::config { $key:
* => $value,
}
}
$transports.each |$key, $value| {
postfix::transport { $key:
* => $value,
}
}
$virtuals.each |$key, $value| {
postfix::virtual { $key:
* => $value,
}
}
$hashes.each |$key, $value| {
postfix::hash { $key:
* => $value,
}
}
$conffiles.each |$key, $value| {
postfix::conffile { $key:
* => $value,
}
}
$maps.each |$key, $value| {
postfix::map { $key:
* => $value,
}
}
contain 'postfix::packages'
contain 'postfix::files'
contain 'postfix::service'
Class['postfix::packages']
-> Class['postfix::files']
~> Class['postfix::service']
if $ldap {
include postfix::ldap
}
if $mta {
if $satellite {
fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
}
include postfix::mta
}
if $satellite {
if $mta {
fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
}
include postfix::satellite
}
if $mailman {
include postfix::mailman
}
}