Retire debian_org::mail_incoming_port which did the default firewalling for the mail...
[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   munin::check { 'ps_exim4':       ensure => absent }
26   munin::check { 'exim_mailqueue': ensure => absent }
27   munin::check { 'exim_mailstats': ensure => absent }
28
29   munin::check { 'postfix_mailqueue': }
30   munin::check { 'postfix_mailstats': }
31   munin::check { 'postfix_mailvolume': }
32   munin::check { 'ps_smtp': script => 'ps_' }
33   munin::check { 'ps_smtpd': script => 'ps_' }
34
35   if $manage_maincf {
36     concat { '/etc/postfix/main.cf':
37       notify  => Exec['service postfix reload'],
38     }
39     concat::fragment { 'puppet-postfix-main.cf--header':
40       target  => '/etc/postfix/main.cf',
41       order   => '000',
42       content => template('postfix/main.cf-header.erb')
43     }
44   } else {
45     include fail2ban::postfix
46   }
47
48   exec { 'service postfix reload':
49     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
50     command     => 'service postfix reload',
51     refreshonly => true,
52     require     =>  Package['postfix'],
53   }
54 }