files.pp 2.96 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
  $master_smtp         = $postfix::master_smtp
  $master_smtps        = $postfix::master_smtps
  $master_submission   = $postfix::master_submission
14
  $master_entries      = $postfix::master_entries
15
  $myorigin            = $postfix::myorigin
16
  $manage_root_alias   = $postfix::manage_root_alias
17
  $root_mail_recipient = $postfix::root_mail_recipient
Angel L. Mateo's avatar
Angel L. Mateo committed
18
  $chroot              = $postfix::chroot
19 20 21 22 23
  $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
24

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

Angel L. Mateo's avatar
Angel L. Mateo committed
29 30 31 32 33 34
  $jail = $chroot ? {
    undef   => '-',
    true    => 'y',
    default => 'n',
  }

Raphaël Pinson's avatar
Raphaël Pinson committed
35 36 37 38
  File {
    replace => $manage_conffiles,
  }

39
  file { '/etc/mailname':
Raphaël Pinson's avatar
Raphaël Pinson committed
40
    ensure  => 'file',
41
    content => "${::fqdn}\n",
42
    mode    => '0640',
43 44 45 46 47
    seltype => $postfix::params::seltype,
  }

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

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

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

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

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

Angel L. Mateo's avatar
Angel L. Mateo committed
93
  case $facts['os']['family'] {
94 95 96
    'RedHat': {
      ::postfix::config {
        'mailq_path':       value => '/usr/bin/mailq.postfix';
97 98
        'newaliases_path':  value => '/usr/bin/newaliases.postfix';
        'sendmail_path':    value => '/usr/sbin/sendmail.postfix';
99 100 101 102 103
      }
    }
    default: {}
  }

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

111
}