voxpupuli / puppet-postfix

Puppet postfix module
Apache License 2.0
70 stars 172 forks source link

Missing transport option for transport map #311

Closed ghost closed 1 year ago

ghost commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Valid postfix but breaks module

include ::postfix
postfix::transport { 'local':
  ensure  => present,
  name    => 'example.com',
  nexthop => ":[mailserver.test]:25",
}

Valid puppet but breaks postfix

include ::postfix
postfix::transport { 'local':
  ensure  => present,
  name    => 'example.com',
  nexthop => "[mailserver.test]:25",
}

What are you seeing

Either puppet breaks or mail stops being sent.

# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
C815982D9       551 Thu Oct  7 15:03:25  root@example.local
                                                  (mail transport unavailable)
                                         user@example.com

What behaviour did you expect instead

Support the following valid transport options:

EXAMPLES

        my.domain    :
        .my.domain   :
        *            smtp:outbound-relay.my.domain

        example.com      uucp:example
        .example.com     uucp:example

        example.com      slow:

        example.com      :[gateway.example.com]
        .example.com     :[gateway.example.com]

        example.com      smtp:bar.example:2025

        .example.com     error:mail for *.example.com is not deliverable

(from man 5 transport)

Output log


Debug: Augeas[Postfix transport - example.com](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[Postfix transport - example.com](provider=augeas): sending command 'set' with params ["/files/etc/postfix/transport/pattern[. = 'example.com']", "example.com"]
Debug: Augeas[Postfix transport - example.com](provider=augeas): sending command 'rm' with params ["/files/etc/postfix/transport/pattern[. = 'example.com']/transport"]
Debug: Augeas[Postfix transport - example.com](provider=augeas): sending command 'rm' with params ["/files/etc/postfix/transport/pattern[. = 'example.com']/nexthop"]
Debug: Augeas[Postfix transport - example.com](provider=augeas): sending command 'set' with params ["/files/etc/postfix/transport/pattern[. = 'example.com']/host", ""]
Debug: Augeas[Postfix transport - example.com](provider=augeas): sending command 'set' with params ["/files/etc/postfix/transport/pattern[. = 'example.com']/port", "[mailserver.test]"]
Debug: Augeas[Postfix transport - example.com](provider=augeas): Put failed on one or more files, output from /augeas//error:
Debug: Augeas[Postfix transport - example.com](provider=augeas): /augeas/files/etc/postfix/transport/error = put_failed
Debug: Augeas[Postfix transport - example.com](provider=augeas): /augeas/files/etc/postfix/transport/error/path = /files/etc/postfix/transport/files/etc/postfix/transport/pattern
Debug: Augeas[Postfix transport - example.com](provider=augeas): /augeas/files/etc/postfix/transport/error/lens = /opt/puppetlabs/puppet/share/augeas/lenses/dist/postfix_transport.aug:50.15-52.23:
Debug: Augeas[Postfix transport - example.com](provider=augeas): /augeas/files/etc/postfix/transport/error/message = Failed to match tree under /files/etc/postfix/transport/pattern
 { "host" }
 { "port" = "[mailserver.test]" }

with pattern

{ /transport/ = /([.0-9A-Z_a-z-]+)?/ }
  { /nexthop/ = /(\\[[.0-9A-Z_a-z-]+\\]|[A-Za-z](.*[^\t\n ])?)?/ }
  | { /host/ = /\\[[.0-9A-Z_a-z-]+\\]|[.0-9A-Z_a-z-]+/ }
  { /port/ = /[0-9]+/ }

Debug: AugeasPostfix transport - example.com: Closed the augeas connection Error: /Stage[main]/Main/Postfix::Transport[local]/Augeas[Postfix transport - example.com]: Could not evaluate: Save failed, see debug output for details



## Any additional information you'd like to impart
gcoxmoz commented 2 years ago

285 seems to be the cause. There's no test case in the spec about nexthop => '[nexthop-host]'.

$smtp_nexthop = (String($nexthop) =~ /\[.*\]/) just looks for "does nexthop contain brackets?"

The smtp_nexthop + split area of postfix::transport assumes you'll have a port attached to a nexthop and turn it into a host/port combination, except :port doesn't have to be in nexthop and the code acts like smtp_nexthop guarantees one will be there.

I can't seem to get an environment set up to offer a PR here, but this is definitely a regression since circa ~1.8.0.