files.pp 2.6 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 27 28 29 30 31
    content => "${::fqdn}\n",
    seltype => $postfix::params::seltype,
  }

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

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

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

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

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

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

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

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

101
}