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

4 5
  $alias_maps          = $postfix::all_alias_maps
  $inet_interfaces     = $postfix::inet_interfaces
Jeff Adams's avatar
Jeff Adams committed
6
  $inet_protocols      = $postfix::inet_protocols
7
  $mail_user           = $postfix::mail_user
Raphaël Pinson's avatar
Raphaël Pinson committed
8
  $manage_conffiles    = $postfix::manage_conffiles
9 10
  $maincf_source       = $postfix::maincf_source
  $mastercf_source     = $postfix::mastercf_source
11 12 13 14
  $master_smtp         = $postfix::master_smtp
  $master_smtps        = $postfix::master_smtps
  $master_submission   = $postfix::master_submission
  $myorigin            = $postfix::myorigin
15
  $manage_root_alias   = $postfix::manage_root_alias
16
  $root_mail_recipient = $postfix::root_mail_recipient
17 18 19 20 21
  $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
22

Raphaël Pinson's avatar
Raphaël Pinson committed
23 24 25
  assert_type(Optional[String], $mastercf_source)
  assert_type(Optional[String], $master_smtp)
  assert_type(Optional[String], $master_smtps)
26

Raphaël Pinson's avatar
Raphaël Pinson committed
27 28 29 30
  File {
    replace => $manage_conffiles,
  }

31
  file { '/etc/mailname':
Raphaël Pinson's avatar
Raphaël Pinson committed
32
    ensure  => 'file',
33
    content => "${::fqdn}\n",
34
    mode    => '0644',
35 36 37 38 39
    seltype => $postfix::params::seltype,
  }

  # Aliases
  file { '/etc/aliases':
Raphaël Pinson's avatar
Raphaël Pinson committed
40
    ensure  => 'file',
Raphaël Pinson's avatar
Raphaël Pinson committed
41
    content => "# file managed by puppet\n",
42
    notify  => Exec['newaliases'],
43
    replace => false,
44
    seltype => $postfix::params::aliasesseltype,
45 46 47 48 49 50 51 52 53 54
  }

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

  # Config files
55
  if $mastercf_source {
56 57 58 59
    $mastercf_content = undef
  } else {
    $mastercf_content = template(
        $postfix::params::master_os_template,
60
        'postfix/master.cf.common.erb'
61 62 63
      )
  }

64
  file { '/etc/postfix/master.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
65
    ensure  => 'file',
66
    content => $mastercf_content,
67 68
    group   => 'root',
    mode    => '0644',
69
    owner   => 'root',
70
    seltype => $postfix::params::seltype,
71
    source  => $mastercf_source,
72 73 74 75
  }

  # Config files
  file { '/etc/postfix/main.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
76
    ensure  => 'file',
77 78
    group   => 'root',
    mode    => '0644',
79
    owner   => 'root',
80 81
    replace => false,
    seltype => $postfix::params::seltype,
82
    source  => $maincf_source,
83 84 85
  }

  ::postfix::config {
Raphaël Pinson's avatar
Raphaël Pinson committed
86
    'alias_maps':       value => $alias_maps;
87
    'inet_interfaces':  value => $inet_interfaces;
Jeff Adams's avatar
Jeff Adams committed
88
    'inet_protocols':   value => $inet_protocols;
89
    'myorigin':         value => $myorigin;
90 91 92 93 94 95
  }

  case $::osfamily {
    'RedHat': {
      ::postfix::config {
        'mailq_path':       value => '/usr/bin/mailq.postfix';
96 97
        'newaliases_path':  value => '/usr/bin/newaliases.postfix';
        'sendmail_path':    value => '/usr/sbin/sendmail.postfix';
98 99 100 101 102
      }
    }
    default: {}
  }

103 104 105 106 107
  if $manage_root_alias {
    mailalias {'root':
      recipient => $root_mail_recipient,
      notify    => Exec['newaliases'],
    }
108
  }
109

110
}