2009-08-28 11:15:35 +02:00
|
|
|
#
|
|
|
|
# == Class: postfix
|
2008-12-03 17:53:28 +01:00
|
|
|
#
|
|
|
|
# This class provides a basic setup of postfix with local and remote
|
|
|
|
# delivery and an SMTP server listening on the loopback interface.
|
|
|
|
#
|
2009-08-28 11:15:35 +02:00
|
|
|
# Parameters:
|
|
|
|
# - *$postfix_ng_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_ng_smtp_listen = "192.168.1.10"
|
|
|
|
# include postfix
|
|
|
|
# }
|
|
|
|
#
|
2009-03-02 12:29:31 +01:00
|
|
|
class postfix {
|
2008-12-03 17:53:28 +01:00
|
|
|
|
2009-08-28 11:15:35 +02:00
|
|
|
# selinux labels differ from one distribution to another
|
2009-08-28 09:15:19 +02:00
|
|
|
case $operatingsystem {
|
|
|
|
|
|
|
|
RedHat: {
|
|
|
|
case $lsbmajdistrelease {
|
|
|
|
"4": { $postfix_seltype = "etc_t" }
|
|
|
|
"5": { $postfix_seltype = "postfix_etc_t" }
|
|
|
|
default: { $postfix_seltype = undef }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
$postfix_seltype = undef
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 17:53:28 +01:00
|
|
|
# Default value for various options
|
2009-12-22 20:28:15 +01:00
|
|
|
case $postfix_smtp_listen {
|
|
|
|
"": { $postfix_smtp_listen = "127.0.0.1" }
|
2008-12-03 17:53:28 +01:00
|
|
|
}
|
|
|
|
case $root_mail_recipient {
|
|
|
|
"": { $root_mail_recipient = "nobody" }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
package { ["postfix", "mailx"]:
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
service { "postfix":
|
|
|
|
ensure => running,
|
|
|
|
require => Package["postfix"],
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/etc/mailname":
|
|
|
|
ensure => present,
|
|
|
|
content => "${fqdn}\n",
|
2009-08-28 09:15:19 +02:00
|
|
|
seltype => $postfix_seltype,
|
2008-12-03 17:53:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Aliases
|
|
|
|
file { "/etc/aliases":
|
|
|
|
ensure => present,
|
|
|
|
content => "# file managed by puppet\n",
|
|
|
|
replace => false,
|
2009-08-28 09:15:19 +02:00
|
|
|
seltype => $postfix_seltype,
|
2008-12-03 17:53:28 +01:00
|
|
|
notify => Exec["newaliases"],
|
|
|
|
}
|
|
|
|
|
2009-08-28 11:15:35 +02:00
|
|
|
# Aliases
|
2008-12-03 17:53:28 +01:00
|
|
|
exec { "newaliases":
|
|
|
|
command => "/usr/bin/newaliases",
|
|
|
|
refreshonly => true,
|
|
|
|
require => Package["postfix"],
|
|
|
|
subscribe => File["/etc/aliases"],
|
|
|
|
}
|
|
|
|
|
|
|
|
# Config files
|
|
|
|
file { "/etc/postfix/master.cf":
|
|
|
|
ensure => present,
|
2009-05-26 12:52:54 +02:00
|
|
|
owner => "root",
|
|
|
|
mode => "0644",
|
2009-03-02 12:41:13 +01:00
|
|
|
content => $operatingsystem ? {
|
|
|
|
Redhat => template("postfix/master.cf.redhat5.erb"),
|
|
|
|
Debian => template("postfix/master.cf.debian-etch.erb"),
|
2008-12-03 17:53:28 +01:00
|
|
|
},
|
2009-08-28 09:15:19 +02:00
|
|
|
seltype => $postfix_seltype,
|
2008-12-03 17:53:28 +01:00
|
|
|
notify => Service["postfix"],
|
|
|
|
require => Package["postfix"],
|
|
|
|
}
|
|
|
|
|
2009-08-28 11:15:35 +02:00
|
|
|
# Config files
|
2008-12-03 17:53:28 +01:00
|
|
|
file { "/etc/postfix/main.cf":
|
|
|
|
ensure => present,
|
2009-05-26 12:52:54 +02:00
|
|
|
owner => "root",
|
|
|
|
mode => "0644",
|
2009-03-02 12:29:31 +01:00
|
|
|
source => "puppet:///postfix/main.cf",
|
2008-12-03 17:53:28 +01:00
|
|
|
replace => false,
|
2009-08-28 09:15:19 +02:00
|
|
|
seltype => $postfix_seltype,
|
2008-12-03 17:53:28 +01:00
|
|
|
notify => Service["postfix"],
|
|
|
|
require => Package["postfix"],
|
|
|
|
}
|
|
|
|
|
|
|
|
# Default configuration parameters
|
2009-03-02 12:29:31 +01:00
|
|
|
postfix::config {
|
2008-12-03 17:53:28 +01:00
|
|
|
"myorigin": value => "${fqdn}";
|
|
|
|
"alias_maps": value => "hash:/etc/aliases";
|
|
|
|
"inet_interfaces": value => "all";
|
|
|
|
}
|
|
|
|
|
|
|
|
case $operatingsystem {
|
|
|
|
RedHat: {
|
2009-03-02 12:29:31 +01:00
|
|
|
postfix::config {
|
2008-12-03 17:53:28 +01:00
|
|
|
"sendmail_path": value => "/usr/sbin/sendmail.postfix";
|
|
|
|
"newaliases_path": value => "/usr/bin/newaliases.postfix";
|
|
|
|
"mailq_path": value => "/usr/bin/mailq.postfix";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mailalias {"root":
|
|
|
|
recipient => $root_mail_recipient,
|
|
|
|
notify => Exec["newaliases"],
|
|
|
|
}
|
|
|
|
}
|