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

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
  $manage_root_alias   = $postfix::manage_root_alias
13
  $root_mail_recipient = $postfix::root_mail_recipient
14 15 16 17 18
  $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
19

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

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

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

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

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

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

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

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

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

95 96 97 98 99
  if $manage_root_alias {
    mailalias {'root':
      recipient => $root_mail_recipient,
      notify    => Exec['newaliases'],
    }
100
  }
101

102
}