Puppet Class: postfix

Inherits:
postfix::params
Defined in:
manifests/init.pp

Overview

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)

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_options
  • (string)

mail_user
  • (string) The mail user

mailman
  • (boolean)

maincf_source
  • (string)

manage_conffiles
  • (boolean) Whether config files are to be replaced

manage_mailx
  • (boolean) Whether to manage mailx package.

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',
}

Parameters:

  • confdir (Stdlib::Absolutepath) (defaults to: '/etc/postfix')
  • root_group (String) (defaults to: 'root')
  • alias_maps (String) (defaults to: 'hash:/etc/aliases')
  • configs (Optional[Hash]) (defaults to: {})
  • amavis_procs (Integer) (defaults to: 2)
  • inet_interfaces (String) (defaults to: 'all')
  • inet_protocols (String) (defaults to: 'all')
  • ldap (Boolean) (defaults to: false)
  • ldap_base (Optional[String]) (defaults to: undef)
  • ldap_host (Optional[String]) (defaults to: undef)
  • ldap_options (Optional[String]) (defaults to: undef)
  • mail_user (String) (defaults to: 'vmail')
  • mailman (Boolean) (defaults to: false)
  • maincf_source (String) (defaults to: "puppet:///modules/${module_name}/main.cf")
  • manage_conffiles (Boolean) (defaults to: true)
  • manage_mailname (Boolean) (defaults to: true)
  • manage_mailx (Boolean) (defaults to: true)
  • mastercf_source (Optional[String]) (defaults to: undef)
  • mastercf_content (Optional[String]) (defaults to: undef)
  • mastercf_template (Optional[String]) (defaults to: undef)
  • master_smtp (Optional[String]) (defaults to: undef)
  • master_smtps (Optional[String]) (defaults to: undef)
  • master_submission (Optional[String]) (defaults to: undef)
  • master_entries (Optional[Array[String]]) (defaults to: undef)
  • master_bounce_command (String) (defaults to: 'bounce')
  • master_defer_command (String) (defaults to: 'bounce')
  • mta (Boolean) (defaults to: false)
  • mydestination (String) (defaults to: '$myorigin')
  • mynetworks (String) (defaults to: '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128')
  • myorigin (String) (defaults to: $::fqdn)
  • manage_aliases (Boolean) (defaults to: true)
  • relayhost (Optional[String]) (defaults to: undef)
  • manage_root_alias (Boolean) (defaults to: true)
  • root_mail_recipient (Variant[Array[String], String]) (defaults to: 'nobody')
  • chroot (Optional[Boolean]) (defaults to: undef)
  • satellite (Boolean) (defaults to: false)
  • smtp_listen (String) (defaults to: '127.0.0.1')
  • use_amavisd (Boolean) (defaults to: false)
  • use_dovecot_lda (Boolean) (defaults to: false)
  • use_schleuder (Variant[Integer[2, 3], Boolean]) (defaults to: false)
  • use_sympa (Boolean) (defaults to: false)
  • postfix_ensure (String) (defaults to: 'present')
  • mailx_ensure (String) (defaults to: 'present')
  • service_ensure (String) (defaults to: 'running')
  • service_enabled (Boolean) (defaults to: true)


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
# File 'manifests/init.pp', line 95

class postfix (
  Stdlib::Absolutepath            $confdir             = '/etc/postfix',
  String                          $root_group          = 'root',
  String                          $alias_maps          = 'hash:/etc/aliases',
  Optional[Hash]                  $configs             = {},
  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_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[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
  Optional[Array[String]]         $master_entries      = undef,         # 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            = $::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,
  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
  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",
  }

  create_resources('::postfix::config', $configs)

  anchor { 'postfix::begin': }
  -> class { '::postfix::packages': }
  -> class { '::postfix::files': }
  ~> class { '::postfix::service': }
  -> anchor { 'postfix::end': }

  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
  }
}