files.pp 3.11 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    => '0644',
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
56
57
58
59
60
61
62
  }

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

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

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

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

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

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

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

118
}