files.pp 1.86 KB
Newer Older
Raphaël Pinson's avatar
Raphaël Pinson committed
1
class postfix::files (
2 3
  $smtp_listen,
  $root_mail_recipient,
Raphaël Pinson's avatar
Raphaël Pinson committed
4 5 6 7 8
  $use_amavisd,
  $use_dovecot_lda,
  $use_schleuder,
  $use_sympa,
  $mail_user,
9 10
  $myorigin,
  $inet_interfaces,
Raphaël Pinson's avatar
Raphaël Pinson committed
11 12 13 14
  $master_smtp,
  $master_smtps,
  $master_submission,
) {
15 16 17 18 19 20 21 22 23 24 25
  include postfix::params

  file { '/etc/mailname':
    ensure  => present,
    content => "${::fqdn}\n",
    seltype => $postfix::params::seltype,
  }

  # Aliases
  file { '/etc/aliases':
    ensure  => present,
Raphaël Pinson's avatar
Raphaël Pinson committed
26
    content => "# file managed by puppet\n",
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    replace => false,
    seltype => $postfix::params::seltype,
    notify  => Exec['newaliases'],
  }

  # Aliases
  exec { 'newaliases':
    command     => '/usr/bin/newaliases',
    refreshonly => true,
    subscribe   => File['/etc/aliases'],
  }

  # Config files
  file { '/etc/postfix/master.cf':
    ensure  => present,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template(
      $postfix::params::master_os_template,
      "${module_name}/master.cf.common.erb"
    ),
    seltype => $postfix::params::seltype,
  }

  # Config files
  file { '/etc/postfix/main.cf':
    ensure  => present,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    source  => "puppet:///modules/${module_name}/main.cf",
    replace => false,
    seltype => $postfix::params::seltype,
  }

  ::postfix::config {
64
    'myorigin':         value => $myorigin;
65
    'alias_maps':       value => 'hash:/etc/aliases';
66
    'inet_interfaces':  value => $inet_interfaces;
67 68 69 70 71 72 73 74 75 76 77 78 79 80
  }

  case $::osfamily {
    'RedHat': {
      ::postfix::config {
        'sendmail_path':    value => '/usr/sbin/sendmail.postfix';
        'newaliases_path':  value => '/usr/bin/newaliases.postfix';
        'mailq_path':       value => '/usr/bin/mailq.postfix';
      }
    }
    default: {}
  }

  mailalias {'root':
81
    recipient => $root_mail_recipient,
82 83 84
    notify    => Exec['newaliases'],
  }
}