Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Puppet Camptocamp Postfix
Commits
2d6af793
Commit
2d6af793
authored
Oct 18, 2011
by
Issey Llambias
Committed by
Raphaël Pinson
Sep 10, 2012
Browse files
Add hasstatus, enable and restart to postfix service in postfix classe
parent
2ed15824
Changes
9
Show whitespace changes
Inline
Side-by-side
manifests/classes/postfix-ldap.pp
0 → 100644
View file @
2d6af793
class
postfix::ldap
inherits
postfix
{
Postfix
::
Config
[
"alias_maps"
]
{
value
=>
"'hash:/etc/aliases, ldap:/etc/postfix/ldap-aliases.cf'"
,
}
package
{
"postfix-ldap"
:
}
if
!
$postfix_ldap_base
{
fail
'Missing $postfix_ldap_base !'
}
file
{
"/etc/postfix/ldap-aliases.cf"
:
ensure
=>
present
,
owner
=>
root
,
group
=>
postfix
,
content
=>
template
(
"postfix/postfix-ldap-aliases.cf.erb"
),
require
=>
Package
[
"postfix-ldap"
],
}
}
manifests/classes/postfix-mailman.pp
0 → 100644
View file @
2d6af793
#
# == Class: postfix::mailman
#
# Configures a basic smtp server, able to work for the mailman mailing-list
# manager.
#
# Parameters:
# - every global variable which works for class "postfix" will work here.
#
# Example usage:
#
# node "toto.example.com" {
# include mailman
# include postfix::mailman
# }
#
class
postfix::mailman
{
$postfix_smtp_listen
=
"0.0.0.0"
include
postfix
postfix::config
{
"virtual_alias_maps"
:
value
=>
"hash:/etc/postfix/virtual"
;
"transport_maps"
:
value
=>
"hash:/etc/postfix/transport"
;
"mailman_destination_recipient_limit"
:
value
=>
"1"
;
}
postfix::hash
{
"/etc/postfix/virtual"
:
ensure
=>
present
,
}
postfix::hash
{
"/etc/postfix/transport"
:
ensure
=>
present
,
}
}
manifests/classes/postfix-mta.pp
0 → 100644
View file @
2d6af793
#
# == Class: postfix::mta
#
# This class configures a minimal MTA, listening on
# $postfix_smtp_listen (default to localhost) and delivering mail to
# $postfix_mydestination (default to $fqdn).
#
# A valid relay host is required ($postfix_relayhost) for outbound email.
#
# transport & virtual maps get configured and can be populated with
# postfix::transport and postfix::virtual
#
# Parameters:
# - *$postfix_relayhost*
# - *$postfix_mydestination*
# - every global variable which works for class "postfix" will work here.
#
# Example usage:
#
# node "toto.example.com" {
# $postfix_relayhost = "mail.example.com"
# $postfix_smtp_listen = "0.0.0.0"
# $postfix_mydestination = "\$myorigin, myapp.example.com"
#
# include postfix::mta
#
# postfix::transport { "myapp.example.com":
# ensure => present,
# destination => "local:",
# }
# }
#
class
postfix::mta
{
case
$postfix_relayhost
{
""
:
{
fail
(
"Required
\$
postfix_relayhost variable is not defined."
)
}
}
case
$postfix_mydestination
{
""
:
{
$postfix_mydestination
=
"
\$
myorigin"
}
}
include
postfix
postfix::config
{
"mydestination"
:
value
=>
$postfix_mydestination
;
"mynetworks"
:
value
=>
"127.0.0.0/8"
;
"relayhost"
:
value
=>
$postfix_relayhost
;
"virtual_alias_maps"
:
value
=>
"hash:/etc/postfix/virtual"
;
"transport_maps"
:
value
=>
"hash:/etc/postfix/transport"
;
}
postfix::hash
{
"/etc/postfix/virtual"
:
ensure
=>
present
,
}
postfix::hash
{
"/etc/postfix/transport"
:
ensure
=>
present
,
}
}
manifests/classes/postfix-satellite.pp
0 → 100644
View file @
2d6af793
#
# == Class: postfix::satellite
#
# This class configures all local email (cron, mdadm, etc) to be forwarded
# to $root_mail_recipient, using $postfix_relayhost as a relay.
#
# $valid_fqdn can be set to override $fqdn in the case where the FQDN is
# not recognized as valid by the destination server.
#
# Parameters:
# - *valid_fqdn*
# - every global variable which works for class "postfix" will work here.
#
# Example usage:
#
# node "toto.local.lan" {
# $postfix_relayhost = "mail.example.com"
# $valid_fqdn = "toto.example.com"
# $root_mail_recipient = "the.sysadmin@example.com"
#
# include postfix::satellite
# }
#
class
postfix::satellite
{
# If $valid_fqdn exists, use it to override $fqdn
case
$valid_fqdn
{
""
:
{
$valid_fqdn
=
$fqdn
}
default
:
{
$fqdn
=
"
${valid_fqdn}
"
}
}
include
postfix::mta
postfix::virtual
{
"@
${valid_fqdn}
"
:
ensure
=>
present
,
destination
=>
"root"
,
}
}
manifests/classes/postfix.pp
0 → 100644
View file @
2d6af793
#
# == 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"
,
"6"
:
{
$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_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_mail_user
{
""
:
{
$postfix_mail_user
=
"vmail"
}
}
package
{
"postfix"
:
ensure
=>
installed
}
package
{
"mailx"
:
ensure
=>
installed
,
name
=>
$lsbdistcodename
?
{
"squeeze"
=>
"bsd-mailx"
,
default
=>
"mailx"
,
},
}
service
{
"postfix"
:
ensure
=>
running
,
enable
=>
true
,
hasstatus
=>
true
,
restart
=>
"/etc/init.d/postfix reload"
,
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|CentOS/
=>
template
(
"postfix/master.cf.redhat.erb"
,
"postfix/master.cf.common.erb"
),
/Debian|Ubuntu|kFreeBSD/
=>
template
(
"postfix/master.cf.debian.erb"
,
"postfix/master.cf.common.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"
;
}
}
}
mailalias
{
"root"
:
recipient
=>
$root_mail_recipient
,
notify
=>
Exec
[
"newaliases"
],
}
}
manifests/definitions/config.pp
0 → 100644
View file @
2d6af793
/*
==
Definition
:
postfix::config
Uses
the
"postconf"
command
to
add
/
alter
/
remove
options
in
postfix
main
configuation
file
(
/
etc
/
postfix
/
main
.
cf
)
.
Parameters
:
-
*
name
*
:
name
of
the
parameter
.
-
*
ensure
*
:
present
/
absent
.
defaults
to
present
.
-
*
value
*
:
value
of
the
parameter
.
Requires
:
-
Class
[
"postfix"
]
Example
usage
:
node
"toto.example.com"
{
include
postfix
postfix::config
{
"smtp_use_tls"
=>
"yes"
;
"smtp_sasl_auth_enable"
=>
"yes"
;
"smtp_sasl_password_maps"
=>
"hash:/etc/postfix/my_sasl_passwords"
;
"relayhost"
=>
"[mail.example.com]:587"
;
}
}
*/
define
postfix::config
(
$ensure
=
present
,
$value
)
{
Augeas
{
context
=>
"/files/etc/postfix/main.cf"
,
notify
=>
Service
[
"postfix"
],
require
=>
File
[
"/etc/postfix/main.cf"
],
}
case
$ensure
{
present
:
{
augeas
{
"set postfix
$name
to
$value
"
:
changes
=>
"set
$name
$value
"
,
}
}
absent
:
{
augeas
{
"set postfix
$name
to
$value
"
:
changes
=>
"rm
$name
"
,
}
}
}
}
manifests/definitions/hash.pp
0 → 100644
View file @
2d6af793
/*
==
Definition
:
postfix::hash
Creates
postfix
hashed
"map"
files
.
It
will
create
"
${name}
"
,
and
then
build
"
${name}
.db"
using
the
"postmap"
command
.
The
map
file
can
then
be
referred
to
using
postfix::config
.
Parameters
:
-
*
name
*
:
the
name
of
the
map
file
.
-
*
ensure
*
:
present
/
absent
,
defaults
to
present
.
-
*
source
*
:
file
source
.
Requires
:
-
Class
[
"postfix"
]
Example
usage
:
node
"toto.example.com"
{
include
postfix
postfix::hash
{
"/etc/postfix/virtual"
:
ensure
=>
present
,
}
postfix::config
{
"virtual_alias_maps"
:
value
=>
"hash:/etc/postfix/virtual"
}
}
*/
define
postfix::hash
(
$ensure
=
"present"
,
$source
=
false
)
{
# selinux labels differ from one distribution to another
case
$operatingsystem
{
RedHat
,
CentOS
:
{
case
$lsbmajdistrelease
{
"4"
:
{
$postfix_seltype
=
"etc_t"
}
"5"
,
"6"
:
{
$postfix_seltype
=
"postfix_etc_t"
}
default
:
{
$postfix_seltype
=
undef
}
}
}
default
:
{
$postfix_seltype
=
undef
}
}
case
$source
{
false
:
{
file
{
"
${name}
"
:
ensure
=>
$ensure
,
mode
=>
600
,
owner
=>
root
,
group
=>
root
,
seltype
=>
$postfix_seltype
,
require
=>
Package
[
"postfix"
],
}
}
default
:
{
file
{
"
${name}
"
:
ensure
=>
$ensure
,
mode
=>
600
,
owner
=>
root
,
group
=>
root
,
source
=>
$source
,
seltype
=>
$postfix_seltype
,
require
=>
Package
[
"postfix"
],
}
}
}
file
{
"
${name}
.db"
:
ensure
=>
$ensure
,
mode
=>
600
,
require
=>
[
File
[
"
${name}
"
],
Exec
[
"generate
${name}
.db"
]],
seltype
=>
$postfix_seltype
,
}
exec
{
"generate
${name}
.db"
:
command
=>
"postmap
${name}
"
,
#creates => "${name}.db", # this prevents postmap from being run !
subscribe
=>
File
[
"
${name}
"
],
refreshonly
=>
true
,
require
=>
Package
[
"postfix"
],
}
}
manifests/definitions/transport.pp
0 → 100644
View file @
2d6af793
/*
==
Definition
:
postfix::transport
Manages
content
of
the
/
etc
/
postfix
/
transport
map
.
Parameters
:
-
*
name
*
:
name
of
address
postfix
will
lookup
.
See
transport
(
5
)
.
-
*
destination
*
:
where
the
emails
will
be
delivered
to
.
See
transport
(
5
)
.
-
*
ensure
*
:
present
/
absent
,
defaults
to
present
.
Requires
:
-
Class
[
"postfix"
]
-
Postfix
::
Hash
[
"/etc/postfix/transport"
]
-
Postfix
::
Config
[
"transport_maps"
]
-
common::line
(
from
module
common
)
Example
usage
:
node
"toto.example.com"
{
include
postfix
postfix::hash
{
"/etc/postfix/transport"
:
ensure
=>
present
,
}
postfix::config
{
"transport_maps"
:
value
=>
"hash:/etc/postfix/transport"
}
postfix::transport
{
"mailman.example.com"
:
ensure
=>
present
,
destination
=>
"mailman"
,
}
}
*/
define
postfix::transport
(
$ensure
=
"present"
,
$destination
)
{
line
{
"
${name}
${destination}
"
:
ensure
=>
$ensure
,
file
=>
"/etc/postfix/transport"
,
line
=>
"
${name}
${destination}
"
,
notify
=>
Exec
[
"generate /etc/postfix/transport.db"
],
require
=>
Package
[
"postfix"
],
}
}
manifests/definitions/virtual.pp
0 → 100644
View file @
2d6af793
/*
==
Definition
:
postfix::virtual
Manages
content
of
the
/
etc
/
postfix
/
virtual
map
.
Parameters
:
-
*
name
*
:
name
of
address
postfix
will
lookup
.
See
virtual
(
8
)
.
-
*
destination
*
:
where
the
emails
will
be
delivered
to
.
See
virtual
(
8
)
.
-
*
ensure
*
:
present
/
absent
,
defaults
to
present
.
Requires
:
-
Class
[
"postfix"
]
-
Postfix
::
Hash
[
"/etc/postfix/virtual"
]
-
Postfix
::
Config
[
"virtual_alias_maps"
]
-
common::line
(
from
module
common
)
Example
usage
:
node
"toto.example.com"
{
include
postfix
postfix::hash
{
"/etc/postfix/virtual"
:
ensure
=>
present
,
}
postfix::config
{
"virtual_alias_maps"
:
value
=>
"hash:/etc/postfix/virtual"
}
postfix::virtual
{
"user@example.com"
:
ensure
=>
present
,
destination
=>
"root"
,
}
}
*/
define
postfix::virtual
(
$ensure
=
"present"
,
$destination
)
{
line
{
"
${name}
${destination}
"
:
ensure
=>
$ensure
,
file
=>
"/etc/postfix/virtual"
,
line
=>
"
${name}
${destination}
"
,
notify
=>
Exec
[
"generate /etc/postfix/virtual.db"
],
require
=>
Package
[
"postfix"
],
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment