init.pp 4.54 KB
Newer Older
1
2
3
4
5
6
#
# == Class: postfix
#
# This class provides a basic setup of postfix with local and remote
# delivery and an SMTP server listening on the loopback interface.
#
Raphaël Pinson's avatar
Raphaël Pinson committed
7
8
# === Parameters
#
Raphaël Pinson's avatar
Raphaël Pinson committed
9
10
# [*alias_maps*]          - (string)
#
11
12
# [*inet_interfaces*]     - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
13
# [*ldap*]                - (boolean) Whether to use LDAP
Raphaël Pinson's avatar
Raphaël Pinson committed
14
15
16
#
# [*ldap_base*]           - (string)
#
17
18
19
20
# [*ldap_host*]           - (string)
#
# [*ldap_options*]        - (string)
#
21
22
23
24
# [*mail_user*]           - (string) The mail user
#
# [*mailman*]             - (boolean)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
25
26
# [*maincf_source*]       - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
27
28
# [*manage_conffiles*]    - (boolean) Whether config files are to be replaced
#
Raphaël Pinson's avatar
Raphaël Pinson committed
29
30
# [*mastercf_source*]     - (string)
#
31
32
33
34
35
36
# [*master_smtp*]         - (string)
#
# [*master_smtps*]        - (string)
#
# [*master_submission*]   - (string)
#
37
# [*mta*]                 - (boolean) Configure postfix minimally, as a simple MTA
38
39
40
41
42
43
44
45
46
47
48
#
# [*mydestination*]       - (string)
#
# [*mynetworks*]          - (string)
#
# [*myorigin*]            - (string)
#
# [*relayhost*]           - (string)
#
# [*root_mail_recipient*] - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
49
50
# [*satellite*]           - (boolean) Whether to use as a satellite
#                           (implies MTA)
51
#
Raphaël Pinson's avatar
Raphaël Pinson committed
52
# [*smtp_listen*]         - (string) The SMTP listen interface
53
#
Raphaël Pinson's avatar
Raphaël Pinson committed
54
# [*use_amavisd*]         - (boolean) Whether to setup for Amavis
55
#
Raphaël Pinson's avatar
Raphaël Pinson committed
56
# [*use_dovecot_lda*]     - (boolean) Whether to setup for Dovecot LDA
57
#
Raphaël Pinson's avatar
Raphaël Pinson committed
58
# [*use_schleuder*]       - (boolean) Whether to setup for Schleuder
59
#
Raphaël Pinson's avatar
Raphaël Pinson committed
60
# [*use_sympa*]           - (boolean) Whether to setup for Sympa
61
#
Raphaël Pinson's avatar
Raphaël Pinson committed
62
# === Examples
63
#
Raphaël Pinson's avatar
Raphaël Pinson committed
64
65
#   class { 'postfix':
#     smtp_listen => '192.168.1.10',
66
67
#   }
#
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
68
class postfix (
Raphaël Pinson's avatar
Raphaël Pinson committed
69
  $alias_maps          = 'hash:/etc/aliases',
70
  $inet_interfaces     = 'all',
Raphaël Pinson's avatar
Raphaël Pinson committed
71
72
  $ldap                = false,
  $ldap_base           = undef,
73
74
  $ldap_host           = undef,
  $ldap_options        = undef,
75
  $mail_user           = 'vmail',       # postfix_mail_user
76
  $mailman             = false,
77
  $maincf_source       = "puppet:///modules/${module_name}/main.cf",
Raphaël Pinson's avatar
Raphaël Pinson committed
78
  $manage_conffiles    = true,
79
  $mastercf_source     = undef,
80
81
82
  $master_smtp         = undef,         # postfix_master_smtp
  $master_smtps        = undef,         # postfix_master_smtps
  $master_submission   = undef,         # postfix_master_submission
83
  $mta                 = false,
84
85
  $mydestination       = '$myorigin',   # postfix_mydestination
  $mynetworks          = '127.0.0.0/8', # postfix_mynetworks
86
  $myorigin            = $::fqdn,
87
88
  $relayhost           = undef,         # postfix_relayhost
  $root_mail_recipient = 'nobody',      # root_mail_recipient
89
  $satellite           = false,
90
91
92
93
94
  $smtp_listen         = '127.0.0.1',   # postfix_smtp_listen
  $use_amavisd         = false,         # postfix_use_amavisd
  $use_dovecot_lda     = false,         # postfix_use_dovecot_lda
  $use_schleuder       = false,         # postfix_use_schleuder
  $use_sympa           = false,         # postfix_use_sympa
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
95
96
) inherits postfix::params {

97

Raphaël Pinson's avatar
Raphaël Pinson committed
98
  validate_bool($ldap)
99
100
101
  validate_bool($mailman)
  validate_bool($mta)
  validate_bool($satellite)
102
103
104
105
  validate_bool($use_amavisd)
  validate_bool($use_dovecot_lda)
  validate_bool($use_schleuder)
  validate_bool($use_sympa)
106

Raphaël Pinson's avatar
Raphaël Pinson committed
107
  validate_string($alias_maps)
Raphaël Pinson's avatar
Raphaël Pinson committed
108
  validate_string($inet_interfaces)
Raphaël Pinson's avatar
Raphaël Pinson committed
109
  validate_string($ldap_base)
110
111
  validate_string($ldap_host)
  validate_string($ldap_options)
112
  validate_string($mail_user)
Raphaël Pinson's avatar
Raphaël Pinson committed
113
114
  validate_string($maincf_source)
  validate_string($mastercf_source)
Raphaël Pinson's avatar
Raphaël Pinson committed
115
116
  validate_string($master_smtp)
  validate_string($master_smtps)
117
118
  validate_string($mydestination)
  validate_string($mynetworks)
119
120
  validate_string($myorigin)
  validate_string($relayhost)
121
122
123
  if ! is_array($root_mail_recipient) {
    validate_string($root_mail_recipient)
  }
124
125
  validate_string($smtp_listen)

126

Raphaël Pinson's avatar
Raphaël Pinson committed
127
128
129
130
131

  $_smtp_listen = $mailman ? {
    true    => '0.0.0.0',
    default => $smtp_listen,
  }
132

Raphaël Pinson's avatar
Raphaël Pinson committed
133
  $all_alias_maps = $ldap ? {
Raphaël Pinson's avatar
Raphaël Pinson committed
134
135
    false => $alias_maps,
    true  => "\"${alias_maps}, ldap:/etc/postfix/ldap-aliases.cf\"",
Raphaël Pinson's avatar
Raphaël Pinson committed
136
137
  }

Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
138
  class { 'postfix::packages': } ->
139
  class { 'postfix::files': } ~>
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
140
141
  class { 'postfix::service': } ->
  Class['postfix']
142

Raphaël Pinson's avatar
Raphaël Pinson committed
143
144
145
146
  if $ldap {
    include ::postfix::ldap
  }

147
  if $mta {
148
149
150
    if $satellite {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
151
152
153
154
    include ::postfix::mta
  }

  if $satellite {
155
156
157
    if $mta {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
158
159
    include ::postfix::satellite
  }
Raphaël Pinson's avatar
Raphaël Pinson committed
160

Raphaël Pinson's avatar
Raphaël Pinson committed
161
  if $mailman {
Raphaël Pinson's avatar
Raphaël Pinson committed
162
163
    include ::postfix::mailman
  }
164
165

  # Relationships
Raphaël Pinson's avatar
Raphaël Pinson committed
166
  Postfix::Config <| |> ~> Class['postfix::service']
Raphaël Pinson's avatar
Raphaël Pinson committed
167
  Class['postfix'] -> Postfix::Hash <| |>
168
}