init.pp 4.39 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
27
28
# [*maincf_source*]       - (string)
#
# [*mastercf_source*]     - (string)
#
29
30
31
32
33
34
# [*master_smtp*]         - (string)
#
# [*master_smtps*]        - (string)
#
# [*master_submission*]   - (string)
#
35
# [*mta*]                 - (boolean) Configure postfix minimally, as a simple MTA
36
37
38
39
40
41
42
43
44
45
46
#
# [*mydestination*]       - (string)
#
# [*mynetworks*]          - (string)
#
# [*myorigin*]            - (string)
#
# [*relayhost*]           - (string)
#
# [*root_mail_recipient*] - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
47
48
# [*satellite*]           - (boolean) Whether to use as a satellite
#                           (implies MTA)
49
#
Raphaël Pinson's avatar
Raphaël Pinson committed
50
# [*smtp_listen*]         - (string) The SMTP listen interface
51
#
Raphaël Pinson's avatar
Raphaël Pinson committed
52
# [*use_amavisd*]         - (boolean) Whether to setup for Amavis
53
#
Raphaël Pinson's avatar
Raphaël Pinson committed
54
# [*use_dovecot_lda*]     - (boolean) Whether to setup for Dovecot LDA
55
#
Raphaël Pinson's avatar
Raphaël Pinson committed
56
# [*use_schleuder*]       - (boolean) Whether to setup for Schleuder
57
#
Raphaël Pinson's avatar
Raphaël Pinson committed
58
# [*use_sympa*]           - (boolean) Whether to setup for Sympa
59
#
Raphaël Pinson's avatar
Raphaël Pinson committed
60
# === Examples
61
#
Raphaël Pinson's avatar
Raphaël Pinson committed
62
63
#   class { 'postfix':
#     smtp_listen => '192.168.1.10',
64
65
#   }
#
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
66
class postfix (
Raphaël Pinson's avatar
Raphaël Pinson committed
67
  $alias_maps          = 'hash:/etc/aliases',
68
  $inet_interfaces     = 'all',
Raphaël Pinson's avatar
Raphaël Pinson committed
69
70
  $ldap                = false,
  $ldap_base           = undef,
71
72
  $ldap_host           = undef,
  $ldap_options        = undef,
73
  $mail_user           = 'vmail',       # postfix_mail_user
74
  $mailman             = false,
75
76
  $maincf_source       = "puppet:///modules/${module_name}/main.cf",
  $mastercf_source     = undef,
77
78
79
  $master_smtp         = undef,         # postfix_master_smtp
  $master_smtps        = undef,         # postfix_master_smtps
  $master_submission   = undef,         # postfix_master_submission
80
  $mta                 = false,
81
82
  $mydestination       = '$myorigin',   # postfix_mydestination
  $mynetworks          = '127.0.0.0/8', # postfix_mynetworks
83
  $myorigin            = $::fqdn,
84
85
  $relayhost           = undef,         # postfix_relayhost
  $root_mail_recipient = 'nobody',      # root_mail_recipient
86
  $satellite           = false,
87
88
89
90
91
  $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
92
93
) inherits postfix::params {

94

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

Raphaël Pinson's avatar
Raphaël Pinson committed
104
  validate_string($alias_maps)
Raphaël Pinson's avatar
Raphaël Pinson committed
105
  validate_string($inet_interfaces)
Raphaël Pinson's avatar
Raphaël Pinson committed
106
  validate_string($ldap_base)
107
108
  validate_string($ldap_host)
  validate_string($ldap_options)
109
  validate_string($mail_user)
Raphaël Pinson's avatar
Raphaël Pinson committed
110
111
  validate_string($maincf_source)
  validate_string($mastercf_source)
Raphaël Pinson's avatar
Raphaël Pinson committed
112
113
  validate_string($master_smtp)
  validate_string($master_smtps)
114
115
  validate_string($mydestination)
  validate_string($mynetworks)
116
117
118
119
120
  validate_string($myorigin)
  validate_string($relayhost)
  validate_string($root_mail_recipient)
  validate_string($smtp_listen)

121

Raphaël Pinson's avatar
Raphaël Pinson committed
122
123
124
125
126

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

Raphaël Pinson's avatar
Raphaël Pinson committed
128
  $all_alias_maps = $ldap ? {
Raphaël Pinson's avatar
Raphaël Pinson committed
129
130
    false => $alias_maps,
    true  => "\"${alias_maps}, ldap:/etc/postfix/ldap-aliases.cf\"",
Raphaël Pinson's avatar
Raphaël Pinson committed
131
132
  }

Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
133
  class { 'postfix::packages': } ->
134
  class { 'postfix::files': } ~>
Raphaël Pinson's avatar
Linting    
Raphaël Pinson committed
135
136
  class { 'postfix::service': } ->
  Class['postfix']
137

Raphaël Pinson's avatar
Raphaël Pinson committed
138
139
140
141
  if $ldap {
    include ::postfix::ldap
  }

142
  if $mta {
143
144
145
    if $satellite {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
146
147
148
149
    include ::postfix::mta
  }

  if $satellite {
150
151
152
    if $mta {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
153
154
    include ::postfix::satellite
  }
Raphaël Pinson's avatar
Raphaël Pinson committed
155

Raphaël Pinson's avatar
Raphaël Pinson committed
156
  if $mailman {
Raphaël Pinson's avatar
Raphaël Pinson committed
157
158
    include ::postfix::mailman
  }
159
160

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