X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fpostfix%2Fmanifests%2Finit.pp;h=4d5c31d120fc680e695e5e0633dcc758fe5c8fe9;hb=HEAD;hp=3367cbb0479d21f03d17df6ccd7610792680560e;hpb=90ce75f592da77241768d0f865cf21320d68dbe5;p=mirror%2Fdsa-puppet.git diff --git a/modules/postfix/manifests/init.pp b/modules/postfix/manifests/init.pp index 3367cbb04..4d5c31d12 100644 --- a/modules/postfix/manifests/init.pp +++ b/modules/postfix/manifests/init.pp @@ -1,27 +1,54 @@ -class postfix { - package { 'postfix': - ensure => installed - } +# postfix class +# @param use_smarthost use the smarthost +# @param smarthost host to relay through (if set and use_smarthost) +class postfix( + Optional[String] $smarthost, + Boolean $use_smarthost = true, + Boolean $manage_maincf = true, +) { + package { 'postfix': + ensure => installed + } - service { 'postfix': - ensure => running - } + if $use_smarthost { + if ! smarthost { + fail('No smarthost set but use_smarthost is true') + } + } else { + $heavy = true + } - munin::check { 'ps_exim4': ensure => absent } - munin::check { 'exim_mailqueue': ensure => absent } - munin::check { 'exim_mailstats': ensure => absent } + service { 'postfix': + ensure => running + } - munin::check { 'postfix_mailqueue': } - munin::check { 'postfix_mailstats': } - munin::check { 'postfix_mailvolume': } - munin::check { 'ps_smtp': script => 'ps_' } - munin::check { 'ps_smtpd': script => 'ps_' } + munin::check { 'ps_exim4': ensure => absent } + munin::check { 'exim_mailqueue': ensure => absent } + munin::check { 'exim_mailstats': ensure => absent } - if has_role('lists') { - @ferm::rule { 'smtp': - domain => '(ip ip6)', - description => 'Allow smtp access', - rule => '&SERVICE(tcp, 25)' - } - } + munin::check { 'postfix_mailqueue': } + munin::check { 'postfix_mailstats': } + munin::check { 'postfix_mailvolume': } + munin::check { 'ps_smtp': script => 'ps_' } + munin::check { 'ps_smtpd': script => 'ps_' } + + if $manage_maincf { + concat { '/etc/postfix/main.cf': + notify => Exec['service postfix reload'], + } + concat::fragment { 'puppet-postfix-main.cf--header': + target => '/etc/postfix/main.cf', + order => '000', + content => template('postfix/main.cf-header.erb') + } + } else { + include fail2ban::postfix + } + + exec { 'service postfix reload': + path => '/usr/bin:/usr/sbin:/bin:/sbin', + command => 'service postfix reload', + refreshonly => true, + require => Package['postfix'], + } }