switch postfix smarthost config to classparams
[mirror/dsa-puppet.git] / modules / postfix / manifests / init.pp
1 # postfix class
2 # @param use_smarthost use the smarthost
3 # @param smarthost host to relay through (if set and use_smarthost)
4 class postfix(
5   Optional[String] $smarthost,
6   Boolean $use_smarthost = true,
7   Boolean $manage_maincf = true,
8 ) {
9   package { 'postfix':
10     ensure => installed
11   }
12
13   if $use_smarthost {
14     if ! smarthost {
15       fail('No smarthost set but use_smarthost is true')
16     }
17   } else {
18     $heavy = true
19   }
20
21   service { 'postfix':
22     ensure => running
23   }
24
25   include debian_org::mail_incoming_port
26
27   munin::check { 'ps_exim4':       ensure => absent }
28   munin::check { 'exim_mailqueue': ensure => absent }
29   munin::check { 'exim_mailstats': ensure => absent }
30
31   munin::check { 'postfix_mailqueue': }
32   munin::check { 'postfix_mailstats': }
33   munin::check { 'postfix_mailvolume': }
34   munin::check { 'ps_smtp': script => 'ps_' }
35   munin::check { 'ps_smtpd': script => 'ps_' }
36
37   if $manage_maincf {
38     concat { '/etc/postfix/main.cf':
39       notify  => Exec['service postfix reload'],
40     }
41     concat::fragment { 'puppet-postfix-main.cf--header':
42       target  => '/etc/postfix/main.cf',
43       order   => '000',
44       content => template('postfix/main.cf-header.erb')
45     }
46   } else {
47     include fail2ban::postfix
48   }
49
50   exec { 'service postfix reload':
51     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
52     command     => 'service postfix reload',
53     refreshonly => true,
54     require     =>  Package['postfix'],
55   }
56 }