init.pp 5.55 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)
#
Jeff Adams's avatar
Jeff Adams committed
13 14
# [*inet_protocols*]      - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
15
# [*ldap*]                - (boolean) Whether to use LDAP
Raphaël Pinson's avatar
Raphaël Pinson committed
16 17 18
#
# [*ldap_base*]           - (string)
#
19 20 21 22
# [*ldap_host*]           - (string)
#
# [*ldap_options*]        - (string)
#
23 24 25 26
# [*mail_user*]           - (string) The mail user
#
# [*mailman*]             - (boolean)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
27 28
# [*maincf_source*]       - (string)
#
Raphaël Pinson's avatar
Raphaël Pinson committed
29 30
# [*manage_conffiles*]    - (boolean) Whether config files are to be replaced
#
31 32
# [*manage_mailx*]        - (boolean) Whether to manage mailx package.
#
Raphaël Pinson's avatar
Raphaël Pinson committed
33 34
# [*mastercf_source*]     - (string)
#
35 36 37 38 39 40
# [*master_smtp*]         - (string)
#
# [*master_smtps*]        - (string)
#
# [*master_submission*]   - (string)
#
41 42
# [*master_entries*]      - (array of strings)
#
43
# [*mta*]                 - (boolean) Configure postfix minimally, as a simple MTA
44 45 46 47 48 49 50 51 52 53 54
#
# [*mydestination*]       - (string)
#
# [*mynetworks*]          - (string)
#
# [*myorigin*]            - (string)
#
# [*relayhost*]           - (string)
#
# [*root_mail_recipient*] - (string)
#
Angel L. Mateo's avatar
Angel L. Mateo committed
55 56
# [*chroot*]              - (undef/boolean) Whether postfix should be run in a chroot
#
Raphaël Pinson's avatar
Raphaël Pinson committed
57 58
# [*satellite*]           - (boolean) Whether to use as a satellite
#                           (implies MTA)
59
#
Raphaël Pinson's avatar
Raphaël Pinson committed
60
# [*smtp_listen*]         - (string) The SMTP listen interface
61
#
Raphaël Pinson's avatar
Raphaël Pinson committed
62
# [*use_amavisd*]         - (boolean) Whether to setup for Amavis
63
#
Raphaël Pinson's avatar
Raphaël Pinson committed
64
# [*use_dovecot_lda*]     - (boolean) Whether to setup for Dovecot LDA
65
#
Raphaël Pinson's avatar
Raphaël Pinson committed
66
# [*use_schleuder*]       - (boolean) Whether to setup for Schleuder
67
#
Raphaël Pinson's avatar
Raphaël Pinson committed
68
# [*use_sympa*]           - (boolean) Whether to setup for Sympa
69
#
70 71 72 73
# [*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
74
# === Examples
75
#
Raphaël Pinson's avatar
Raphaël Pinson committed
76 77
#   class { 'postfix':
#     smtp_listen => '192.168.1.10',
78 79
#   }
#
Raphaël Pinson's avatar
Linting  
Raphaël Pinson committed
80
class postfix (
Raphaël Pinson's avatar
Raphaël Pinson committed
81 82
  String                          $alias_maps          = 'hash:/etc/aliases',
  String                          $inet_interfaces     = 'all',
Jeff Adams's avatar
Jeff Adams committed
83
  String                          $inet_protocols      = 'all',
Raphaël Pinson's avatar
Raphaël Pinson committed
84 85 86 87 88 89 90 91 92 93 94 95 96
  Boolean                         $ldap                = false,
  Optional[String]                $ldap_base           = undef,
  Optional[String]                $ldap_host           = undef,
  Optional[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_mailx        = true,
  Optional[String]                $mastercf_source     = 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
97
  Optional[Array[String]]         $master_entries      = undef,         # postfix_master_entries
Raphaël Pinson's avatar
Raphaël Pinson committed
98 99 100 101 102 103 104
  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            = $::fqdn,
  Optional[String]                $relayhost           = undef,         # postfix_relayhost
  Boolean                         $manage_root_alias   = true,
  Variant[Array[String], String]  $root_mail_recipient = 'nobody',      # root_mail_recipient
Angel L. Mateo's avatar
Angel L. Mateo committed
105
  Optional[Boolean]               $chroot              = undef,
Raphaël Pinson's avatar
Raphaël Pinson committed
106 107 108 109 110 111 112 113
  Boolean                         $satellite           = false,
  String                          $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
  Boolean                         $use_schleuder       = false,         # postfix_use_schleuder
  Boolean                         $use_sympa           = false,         # postfix_use_sympa
  String                          $postfix_ensure      = 'present',
  String                          $mailx_ensure        = 'present',
114 115
  String                          $service_ensure      = 'running',
  Boolean                         $service_enabled     =  true,
Raphaël Pinson's avatar
Linting  
Raphaël Pinson committed
116 117
) inherits postfix::params {

Raphaël Pinson's avatar
Raphaël Pinson committed
118 119 120 121
  $_smtp_listen = $mailman ? {
    true    => '0.0.0.0',
    default => $smtp_listen,
  }
122

Raphaël Pinson's avatar
Raphaël Pinson committed
123
  $all_alias_maps = $ldap ? {
Raphaël Pinson's avatar
Raphaël Pinson committed
124
    false => $alias_maps,
Ben Hocker's avatar
Ben Hocker committed
125
    true  => "${alias_maps}, ldap:/etc/postfix/ldap-aliases.cf",
Raphaël Pinson's avatar
Raphaël Pinson committed
126 127
  }

Mickaël Canévet's avatar
Mickaël Canévet committed
128 129 130 131 132
  anchor { 'postfix::begin': }
  -> class { '::postfix::packages': }
  -> class { '::postfix::files': }
  ~> class { '::postfix::service': }
  -> anchor { 'posfix::end': }
133

Raphaël Pinson's avatar
Raphaël Pinson committed
134 135 136 137
  if $ldap {
    include ::postfix::ldap
  }

138
  if $mta {
139 140 141
    if $satellite {
      fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.')
    }
142 143 144 145
    include ::postfix::mta
  }

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

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