Commit a9878376 authored by Ewoud Kohl van Wijngaarden's avatar Ewoud Kohl van Wijngaarden
Browse files

Allow blank destinations

It's possible to have a blank destination. A typical use case is discarding
everything except one domain[1].

example.org :
.example.org :
* discard:

One would implement this using puppet-postfix as follows:

postfix::transport { ['example.org', '.example.org']:
  destination => '',
}
postfix::transport { '*':
  destination => 'discard',
}

However, this will result into an error:

err: /Stage[main]/MyClass/Postfix::Transport[example.org]/Augeas[Postfix transport - example.org]: Could not evaluate: Save failed with return code false
err: /Stage[main]/MyClass/Postfix::Transport[.example.org]/Augeas[Postfix transport - .example.org]: Could not evaluate: Save failed with return code false

The solution is to use clear instead of set if the destination is empty. This
patch changes the destination to follow a similar pattern as nexthop. For
convenience it also adds a default to destination since that can now be handled
properly. Thus the following works.

postfix::transport { ['example.org', '.example.org']:
}
postfix::transport { '*':
  destination => 'discard',
}

[1]: http://dannyman.toldme.com/2008/09/15/howto-postfix-deliver-external-devnull/
parent bd055b50
......@@ -32,7 +32,7 @@
# }
#
define postfix::transport (
$destination,
$destination='',
$nexthop='',
$file='/etc/postfix/transport',
$ensure='present'
......@@ -41,21 +41,23 @@ define postfix::transport (
case $ensure {
'present': {
if ($destination) {
$change_destination = "set pattern[. = '${name}']/transport '${destination}'"
} else {
$change_destination = "clear pattern[. = '${name}']/transport"
}
if ($nexthop) {
$changes = [
"set pattern[. = '${name}'] '${name}'",
"set pattern[. = '${name}']/transport '${destination}'",
# TODO: support nexthop
"set pattern[. = '${name}']/nexthop '${nexthop}'",
]
$change_nexthop = "set pattern[. = '${name}']/nexthop '${nexthop}'"
} else {
$changes = [
"set pattern[. = '${name}'] '${name}'",
"set pattern[. = '${name}']/transport '${destination}'",
# TODO: support nexthop
"clear pattern[. = '${name}']/nexthop",
]
$change_nexthop = "clear pattern[. = '${name}']/nexthop"
}
$changes = [
"set pattern[. = '${name}'] '${name}'",
$change_destination,
$change_nexthop,
]
}
'absent': {
......
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