view modules/postfix/manifests/init.pp @ 126:8316d4e55e92 puppet-3.6

Fix Apache 2.4 Logwatch support Uses tweaked files from https://sourceforge.net/p/logwatch/git/ci/2ecdeb6e3b62814ad69e7371e69d2a26315fc45e/ We need to use "http-error-24.conf" so that Logwatch doesn't apply standard HTTP date formats to the error log and lose all log messages (Also includes a fix to remove a file from Puppet that we removed from disk - not committed separately because I didn't find it until I went to puppet apply this, and I couldn't be bothered rushing to work out how to do partial commits)
author IBBoard <dev@ibboard.co.uk>
date Tue, 13 Sep 2016 21:04:40 +0100
parents 28a4e01b904b
children 0dd899a10ee1
line wrap: on
line source

class postfix (
  $mailserver,
  ){
  package { 'sendmail':
    ensure => 'absent',
  }
  service { 'sendmail':
    ensure => stopped,
  }
  package { 'postfix':
    ensure => latest;
  }
  service { 'postfix':
    ensure    => running,
    subscribe => Package['postfix'],
  }
  exec { 'postmap-files':
    command     => 'for file in helo_whitelist recipient_bcc sender_access valias valias-blacklist virtual vmailbox; do postmap $file; done',
    cwd         => '/etc/postfix/',
    provider    => 'shell',
    refreshonly => true,
    notify      => Service['postfix'],
  }
  File {
    ensure  => present,
    notify  => Exec['postmap-files'],
    require => Package['postfix'],
  }
  file { '/etc/postfix/main.cf':
    content => template('postfix/main.cf.erb'),
  }
  file { '/etc/postfix/master.cf':
    source => [
      "puppet:///modules/postfix/master.${operatingsystem}${operatingsystemmajrelease}.cf",
      'puppet:///modules/postfix/master.cf'
    ]
  }
  #Hosted domains
  file { '/etc/postfix/vdomains':
    source => 'puppet:///private/postfix/vdomains',
  }
  #Hosted mailboxes
  file { '/etc/postfix/vmailbox':
    source => 'puppet:///private/postfix/vmailbox',
  }
  #Catch-alls
  file { '/etc/postfix/virtual':
    source => 'puppet:///private/postfix/virtual',
  }
  #Forwarders/aliases
  file { '/etc/postfix/valias':
    source => 'puppet:///private/postfix/valias',
  }
  #BCCing of inbound email
  file { '/etc/postfix/recipient_bcc':
    source => 'puppet:///private/postfix/recipient_bcc',
  }
  #Spammed/removed addresses
  file { '/etc/postfix/valias-blacklist':
    source => 'puppet:///private/postfix/valias-blacklist',
  }
  #Spammed/removed address patterns
  file { '/etc/postfix/valias-blacklist-regex':
    source => 'puppet:///private/postfix/valias-blacklist-regex',
  }
  #Bad headers (use sparingly)
  file { '/etc/postfix/header_checks':
    source => 'puppet:///private/postfix/header_checks',
  }
  #Bad headers (use even more sparingly!)
  file { '/etc/postfix/body_checks':
    source => 'puppet:///private/postfix/body_checks',
  }
  #Whitelisted HELO names
  file { '/etc/postfix/helo_whitelist':
    source => 'puppet:///private/postfix/helo_whitelist',
  }
  #Private whitelisted IPs for greylisting process
  file { '/etc/postfix/postscreen_access_private.cidr':
    source => 'puppet:///private/postfix/postscreen_access_private.cidr',
  }
  #Blacklist some domains (e.g. banks who don't do SPF that we don't bank with)
  file { '/etc/postfix/sender_access':
    source => 'puppet:///private/postfix/sender_access',
  }
  # Certificates
  file { "/etc/pki/custom/$mailserver.crt":
    ensure => present,
    source => "puppet:///private/pki/custom/$mailserver.crt",
    owner  => 'postfix',
    mode   => 600,
  }
  file { "/etc/pki/custom/$mailserver.key":
    ensure => present,
    source => "puppet:///private/pki/custom/$mailserver.key",
    owner  => 'postfix',
    mode   => 600,
  }

  # Mail base dir
  file { '/var/mail/vhosts/':
    ensure => directory,
    owner => 505,
    group => 505,
    mode => 700,
  } 

  #SPF checking
  file { '/usr/local/lib/postfix-policyd-spf-perl/':
    ensure => directory
  }
  file { '/usr/local/lib/postfix-policyd-spf-perl/postfix-policyd-spf-perl':
    source => 'puppet:///modules/postfix/postfix-policyd-spf-perl',
  }
  $perl_pkgs = [ 'perl', 'perl-NetAddr-IP', 'perl-Mail-SPF', 'perl-version', 'perl-Sys-Hostname-Long']
  package { $perl_pkgs:
    ensure => latest,
  }
}