files.pp 3.06 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
Angel L. Mateo's avatar
Angel L. Mateo committed
17
  $chroot              = $postfix::chroot
18 19 20 21 22
  $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
23

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

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

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

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

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

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

  # Config files
62
  if $mastercf_source {
63 64 65
    $mastercf_content = undef
  } else {
    $mastercf_content = template(
Angel L. Mateo's avatar
Angel L. Mateo committed
66 67 68
      $postfix::params::master_os_template,
      'postfix/master.cf.common.erb'
    )
69 70
  }

71
  file { '/etc/postfix/master.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
72
    ensure  => 'file',
73
    content => $mastercf_content,
74 75
    group   => 'root',
    mode    => '0644',
76
    owner   => 'root',
77
    seltype => $postfix::params::seltype,
78
    source  => $mastercf_source,
79 80 81 82
  }

  # Config files
  file { '/etc/postfix/main.cf':
Raphaël Pinson's avatar
Raphaël Pinson committed
83
    ensure  => 'file',
84 85
    group   => 'root',
    mode    => '0644',
86
    owner   => 'root',
87 88
    replace => false,
    seltype => $postfix::params::seltype,
89
    source  => $maincf_source,
90 91 92
  }

  ::postfix::config {
Raphaël Pinson's avatar
Raphaël Pinson committed
93
    'alias_maps':       value => $alias_maps;
94
    'inet_interfaces':  value => $inet_interfaces;
Jeff Adams's avatar
Jeff Adams committed
95
    'inet_protocols':   value => $inet_protocols;
96
    'myorigin':         value => $myorigin;
97 98
  }

Angel L. Mateo's avatar
Angel L. Mateo committed
99
  case $facts['os']['family'] {
100 101 102
    'RedHat': {
      ::postfix::config {
        'mailq_path':       value => '/usr/bin/mailq.postfix';
103 104
        'newaliases_path':  value => '/usr/bin/newaliases.postfix';
        'sendmail_path':    value => '/usr/sbin/sendmail.postfix';
105 106 107 108 109
      }
    }
    default: {}
  }

110 111 112 113 114
  if $manage_root_alias {
    mailalias {'root':
      recipient => $root_mail_recipient,
      notify    => Exec['newaliases'],
    }
115
  }
116

117
}