Commit 100df32a authored by Todd Eddy's avatar Todd Eddy
Browse files

Allow having mta send mail directly.

parent de609e76
......@@ -9,7 +9,7 @@
# === Parameters
#
# [*name*] - name of the parameter.
# [*ensure*] - present/absent. defaults to present.
# [*ensure*] - present/absent/blank. defaults to present.
# [*value*] - value of the parameter.
#
# === Requires
......@@ -23,12 +23,18 @@
# value => 'yes',
# }
#
define postfix::config ($value, $ensure = present) {
# postfix::config { 'relayhost':
# ensure => 'blank',
# }
#
define postfix::config ($value = undef, $ensure = 'present') {
validate_string($value)
validate_string($ensure)
validate_re($ensure, ['present', 'absent'],
"\$ensure must be either 'present' or 'absent', got '${ensure}'")
validate_re($ensure, ['present', 'absent', 'blank'],
"\$ensure must be either 'present', 'absent' or 'blank', got '${ensure}'")
if ($ensure == 'present') {
validate_string($value)
}
if (!defined(Class['postfix'])) {
fail 'You must define class postfix before using postfix::config!'
......@@ -51,6 +57,11 @@ define postfix::config ($value, $ensure = present) {
changes => "rm ${name}",
}
}
blank: {
augeas { "blank postfix '${name}'":
changes => "clear ${name}",
}
}
default: {}
}
}
......@@ -3,14 +3,16 @@
# This class configures a minimal MTA, delivering mail to
# $mydestination.
#
# A valid relay host is required ($relayhost) for outbound email.
# Either a valid relay host or the special word 'direct' is required
# ($relayhost) for outbound email.
#
# transport & virtual maps get configured and can be populated with
# postfix::transport and postfix::virtual
#
# === Parameters
#
# [*relayhost*] - (string) the relayhost to use
# [*relayhost*] - (string) the relayhost to use or 'direct' to send mail
# directly without a relay.
# [*mydestination*] - (string)
# [*mynetworks*] - (string)
#
......@@ -36,10 +38,17 @@ class postfix::mta (
validate_re($mynetworks, '^\S+$',
'Wrong value for $mynetworks')
# If direct is specified then relayhost should be blank
if ($relayhost == 'direct') {
postfix::config { 'relayhost': ensure => 'blank' }
}
else {
postfix::config { 'relayhost': value => $relayhost }
}
postfix::config {
'mydestination': value => $mydestination;
'mynetworks': value => $mynetworks;
'relayhost': value => $relayhost;
'virtual_alias_maps': value => 'hash:/etc/postfix/virtual';
'transport_maps': value => 'hash:/etc/postfix/transport';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment