files.pp 2.5 KB
Newer Older
1
class postfix::files {
2 3
  include postfix::params

4 5 6
  $alias_maps          = $postfix::all_alias_maps
  $inet_interfaces     = $postfix::inet_interfaces
  $mail_user           = $postfix::mail_user
Raphaël Pinson's avatar
Raphaël Pinson committed
7
  $manage_conffiles    = $postfix::manage_conffiles
8 9 10 11
  $master_smtp         = $postfix::master_smtp
  $master_smtps        = $postfix::master_smtps
  $master_submission   = $postfix::master_submission
  $myorigin            = $postfix::myorigin
12
  $root_mail_recipient = $postfix::root_mail_recipient
13 14 15 16 17
  $smtp_listen         = $postfix::_smtp_listen
  $use_amavisd         = $postfix::use_amavisd
  $use_dovecot_lda     = $postfix::use_dovecot_lda
  $use_schleuder       = $postfix::use_schleuder
  $use_sympa           = $postfix::use_sympa
18

Raphaël Pinson's avatar
Raphaël Pinson committed
19 20 21 22
  File {
    replace => $manage_conffiles,
  }

23
  file { '/etc/mailname':
Raphaël Pinson's avatar
Raphaël Pinson committed
24
    ensure  => 'file',
25 26 27 28 29 30
    content => "${::fqdn}\n",
    seltype => $postfix::params::seltype,
  }

  # Aliases
  file { '/etc/aliases':
Raphaël Pinson's avatar
Raphaël Pinson committed
31
    ensure  => 'file',
Raphaël Pinson's avatar
Raphaël Pinson committed
32
    content => "# file managed by puppet\n",
33
    notify  => Exec['newaliases'],
34 35 36 37 38 39 40 41 42 43 44 45
    replace => false,
    seltype => $postfix::params::seltype,
  }

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

  # Config files
46 47 48 49 50
  if $postfix::mastercf_source {
    $mastercf_content = undef
  } else {
    $mastercf_content = template(
        $postfix::params::master_os_template,
51
        'postfix/master.cf.common.erb'
52 53 54
      )
  }

55
  file { '/etc/postfix/master.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
56
    ensure  => 'file',
57
    content => $mastercf_content,
58 59
    group   => 'root',
    mode    => '0644',
60
    owner   => 'root',
61
    seltype => $postfix::params::seltype,
62
    source  => $postfix::mastercf_source,
63 64 65 66
  }

  # Config files
  file { '/etc/postfix/main.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
67
    ensure  => 'file',
68 69
    group   => 'root',
    mode    => '0644',
70
    owner   => 'root',
71 72
    replace => false,
    seltype => $postfix::params::seltype,
73
    source  => $postfix::maincf_source,
74 75 76
  }

  ::postfix::config {
Raphaël Pinson's avatar
Raphaël Pinson committed
77
    'alias_maps':       value => $alias_maps;
78
    'inet_interfaces':  value => $inet_interfaces;
79
    'myorigin':         value => $myorigin;
80 81 82 83 84 85
  }

  case $::osfamily {
    'RedHat': {
      ::postfix::config {
        'mailq_path':       value => '/usr/bin/mailq.postfix';
86 87
        'newaliases_path':  value => '/usr/bin/newaliases.postfix';
        'sendmail_path':    value => '/usr/sbin/sendmail.postfix';
88 89 90 91 92 93
      }
    }
    default: {}
  }

  mailalias {'root':
94
    recipient => $root_mail_recipient,
95 96 97
    notify    => Exec['newaliases'],
  }
}