init.pp 4.8 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
#
62
63
64
65
# [*postfix_ensure*]      - (string) The ensure value of the postfix package
#
# [*mailx_ensure*]        - (string) The ensure value of the mailx package
#
Raphaël Pinson's avatar
Raphaël Pinson committed
66
# === Examples
67
#
Raphaël Pinson's avatar
Raphaël Pinson committed
68
69
#   class { 'postfix':
#     smtp_listen => '192.168.1.10',
70
71
#   }
#
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
72
class postfix (
Raphaël Pinson's avatar
Raphaël Pinson committed
73
  $alias_maps          = 'hash:/etc/aliases',
74
  $inet_interfaces     = 'all',
Raphaël Pinson's avatar
Raphaël Pinson committed
75
76
  $ldap                = false,
  $ldap_base           = undef,
77
78
  $ldap_host           = undef,
  $ldap_options        = undef,
79
  $mail_user           = 'vmail',       # postfix_mail_user
80
  $mailman             = false,
81
  $maincf_source       = "puppet:///modules/${module_name}/main.cf",
Raphaël Pinson's avatar
Raphaël Pinson committed
82
  $manage_conffiles    = true,
83
  $mastercf_source     = undef,
84
85
86
  $master_smtp         = undef,         # postfix_master_smtp
  $master_smtps        = undef,         # postfix_master_smtps
  $master_submission   = undef,         # postfix_master_submission
87
  $mta                 = false,
88
  $mydestination       = '$myorigin',   # postfix_mydestination
89
  $mynetworks          = '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128', # postfix_mynetworks
90
  $myorigin            = $::fqdn,
91
  $relayhost           = undef,         # postfix_relayhost
92
  $manage_root_alias   = true,
93
  $root_mail_recipient = 'nobody',      # root_mail_recipient
94
  $satellite           = false,
95
96
97
98
99
  $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
100
101
  $postfix_ensure      = 'present',
  $mailx_ensure        = 'present',
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
102
103
) inherits postfix::params {

104

Raphaël Pinson's avatar
Raphaël Pinson committed
105
  validate_bool($ldap)
106
107
  validate_bool($mailman)
  validate_bool($mta)
108
  validate_bool($manage_root_alias)
109
  validate_bool($satellite)
110
111
112
113
  validate_bool($use_amavisd)
  validate_bool($use_dovecot_lda)
  validate_bool($use_schleuder)
  validate_bool($use_sympa)
114

Raphaël Pinson's avatar
Raphaël Pinson committed
115
  validate_string($alias_maps)
Raphaël Pinson's avatar
Raphaël Pinson committed
116
  validate_string($inet_interfaces)
Raphaël Pinson's avatar
Raphaël Pinson committed
117
  validate_string($ldap_base)
118
119
  validate_string($ldap_host)
  validate_string($ldap_options)
120
  validate_string($mail_user)
Raphaël Pinson's avatar
Raphaël Pinson committed
121
122
  validate_string($maincf_source)
  validate_string($mastercf_source)
Raphaël Pinson's avatar
Raphaël Pinson committed
123
124
  validate_string($master_smtp)
  validate_string($master_smtps)
125
126
  validate_string($mydestination)
  validate_string($mynetworks)
127
128
  validate_string($myorigin)
  validate_string($relayhost)
129
130
131
  if ! is_array($root_mail_recipient) {
    validate_string($root_mail_recipient)
  }
132
133
  validate_string($smtp_listen)

134

Raphaël Pinson's avatar
Raphaël Pinson committed
135
136
137
138
139

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

Raphaël Pinson's avatar
Raphaël Pinson committed
141
  $all_alias_maps = $ldap ? {
Raphaël Pinson's avatar
Raphaël Pinson committed
142
    false => $alias_maps,
Ben Hocker's avatar
Ben Hocker committed
143
    true  => "${alias_maps}, ldap:/etc/postfix/ldap-aliases.cf",
Raphaël Pinson's avatar
Raphaël Pinson committed
144
145
  }

Raphaël Pinson's avatar
Raphaël Pinson committed
146
  anchor { 'postfix::begin': } ->
147
148
149
  class { '::postfix::packages': } ->
  class { '::postfix::files': } ~>
  class { '::postfix::service': } ->
Raphaël Pinson's avatar
Raphaël Pinson committed
150
  anchor { 'posfix::end': }
151

Raphaël Pinson's avatar
Raphaël Pinson committed
152
153
154
155
  if $ldap {
    include ::postfix::ldap
  }

156
  if $mta {
157
158
159
    if $satellite {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
160
161
162
163
    include ::postfix::mta
  }

  if $satellite {
164
165
166
    if $mta {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
167
168
    include ::postfix::satellite
  }
Raphaël Pinson's avatar
Raphaël Pinson committed
169

Raphaël Pinson's avatar
Raphaël Pinson committed
170
  if $mailman {
Raphaël Pinson's avatar
Raphaël Pinson committed
171
172
    include ::postfix::mailman
  }
173
}