1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
#
# == Class: postfix
#
# This class provides a basic setup of postfix with local and remote
# delivery and an SMTP server listening on the loopback interface.
#
# Parameters:
# - *$postfix_smtp_listen*: address on which the smtp service will listen to. defaults to 127.0.0.1
# - *$root_mail_recipient*: who will recieve root's emails. defaults to "nobody"
#
# Example usage:
#
# node "toto.example.com" {
# $postfix_smtp_listen = "192.168.1.10"
# include postfix
# }
#
class postfix {
# selinux labels differ from one distribution to another
case $operatingsystem {
RedHat, CentOS: {
case $lsbmajdistrelease {
"4": { $postfix_seltype = "etc_t" }
"5": { $postfix_seltype = "postfix_etc_t" }
default: { $postfix_seltype = undef }
}
}
default: {
$postfix_seltype = undef
}
}
# Default value for various options
case $postfix_smtp_listen {
"": { $postfix_smtp_listen = "127.0.0.1" }
}
case $root_mail_recipient {
"": { $root_mail_recipient = "nobody" }
}
case $postfix_anon_sasl {
"": { $postfix_anon_sasl = "no" }
}
case $postfix_manage_header_checks {
"": { $postfix_manage_header_checks = "no" }
}
case $postfix_manage_tls_policy {
"": { $postfix_manage_tls_policy = "no" }
}
case $postfix_use_amavisd {
"": { $postfix_use_amavisd = "no" }
}
case $postfix_use_dovecot_lda {
"": { $postfix_use_dovecot_lda = "no" }
}
case $postfix_use_schleuder {
"": { $postfix_use_schleuder = "no" }
}
case $postfix_use_sympa {
"": { $postfix_use_sympa = "no" }
}
case $postfix_mastercf_tail {
"": { $postfix_mastercf_tail = "" }
}
# Bootstrap moduledir
include common::moduledir
module_dir{'postfix': }
# Include optional classes
if $postfix_anon_sasl == 'yes' {
include postfix::anonsasl
}
if $postfix_manage_header_checks == 'yes' {
include postfix::header_checks
}
if $postfix_manage_tls_policy == 'yes' {
include postfix::tlspolicy
}
if $postfix_use_amavisd == 'yes' {
include postfix::amavis
}
package { ["postfix", "mailx"]:
ensure => installed
}
if $operatingsystem == 'debian' {
Package[mailx] { name => 'bsd-mailx' }
}
service { "postfix":
ensure => running,
require => Package["postfix"],
}
file { "/etc/mailname":
ensure => present,
content => "${fqdn}\n",
seltype => $postfix_seltype,
}
# Aliases
file { "/etc/aliases":
ensure => present,
content => "# file managed by puppet\n",
replace => false,
seltype => $postfix_seltype,
notify => Exec["newaliases"],
}
# Aliases
exec { "newaliases":
command => "/usr/bin/newaliases",
refreshonly => true,
require => Package["postfix"],
subscribe => File["/etc/aliases"],
}
# Config files
file { "/etc/postfix/master.cf":
ensure => present,
owner => "root",
group => "root",
mode => "0644",
content => $operatingsystem ? {
Redhat => template("postfix/master.cf.redhat5.erb"),
CentOS => template("postfix/master.cf.redhat5.erb"),
Debian => template("postfix/master.cf.debian-$lsbdistcodename.erb"),
Ubuntu => template("postfix/master.cf.debian-etch.erb"),
},
seltype => $postfix_seltype,
notify => Service["postfix"],
require => Package["postfix"],
}
# Config files
file { "/etc/postfix/main.cf":
ensure => present,
owner => "root",
group => "root",
mode => "0644",
source => "puppet:///modules/postfix/main.cf",
replace => false,
seltype => $postfix_seltype,
notify => Service["postfix"],
require => Package["postfix"],
}
# Default configuration parameters
postfix::config {
"myorigin": value => "${fqdn}";
"alias_maps": value => "hash:/etc/aliases";
"inet_interfaces": value => "all";
}
case $operatingsystem {
RedHat, CentOS: {
postfix::config {
"sendmail_path": value => "/usr/sbin/sendmail.postfix";
"newaliases_path": value => "/usr/bin/newaliases.postfix";
"mailq_path": value => "/usr/bin/mailq.postfix";
}
}
}
postfix::mailalias {"root":
recipient => $root_mail_recipient,
}
}
|