files.pp 2.83 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
  $maincf_source       = $postfix::maincf_source
  $mastercf_source     = $postfix::mastercf_source
10 11 12 13
  $master_smtp         = $postfix::master_smtp
  $master_smtps        = $postfix::master_smtps
  $master_submission   = $postfix::master_submission
  $myorigin            = $postfix::myorigin
14
  $manage_root_alias   = $postfix::manage_root_alias
15
  $root_mail_recipient = $postfix::root_mail_recipient
16 17 18 19 20
  $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
21

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

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

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

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

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

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

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

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

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

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

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

108
}