Unverified Commit 6cfefb91 authored by Garrett Honeycutt's avatar Garrett Honeycutt Committed by GitHub
Browse files

Merge pull request #313 from wobblesprout/master

Allow parameter smtp_listen to accept multiple IPs
parents 43ac54a8 432a2f72
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ A Boolean to define whether to configure postfix as a satellite relay host. Thi
Default: False.

##### `smtp_listen`
A string to define the IP on which to listen in master.cf. This can also be set to 'all' to listen on all interfaces. If master_smtp is defined smtp_listen will not be used.
A string or an array of strings to define the IPs on which to listen in master.cf. This can also be set to 'all' to listen on all interfaces. If master_smtp is defined smtp_listen will not be used.
Default: '127.0.0.1'.
Example: '::1'.

+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ class postfix (
  Variant[Array[String], String]  $root_mail_recipient = 'nobody',      # root_mail_recipient
  Optional[Boolean]               $chroot              = undef,
  Boolean                         $satellite           = false,
  String                          $smtp_listen         = '127.0.0.1',   # postfix_smtp_listen
  Variant[Array[String[1]], String[1]] $smtp_listen    = '127.0.0.1',   # postfix_smtp_listen
  Boolean                         $use_amavisd         = false,         # postfix_use_amavisd
  Boolean                         $use_dovecot_lda     = false,         # postfix_use_dovecot_lda
  Variant[Integer[2, 3], Boolean] $use_schleuder       = false,         # postfix_use_schleuder
+26 −2
Original line number Diff line number Diff line
@@ -405,8 +405,32 @@ describe 'postfix' do
          context 'when specifying smtp_listen' do
            let(:params) { { smtp_listen: 'all' } }

            it 'does stuff' do
              skip 'need to write this still'
            it 'updates master.cf to listen to all addresses' do
              is_expected.to contain_file(postfix_master_cf_path).with_content(
                %r{smtp      inet  n       -       n       -       -       smtpd}
              )
            end
          end
          context 'when specifying multiple smtp_listen addresses as string' do
            let(:params) { { smtp_listen: '192.168.0.123 10.0.0.123' } }

            it 'updates master.cf with multiple smtp listeners' do
              is_expected.to contain_file(postfix_master_cf_path).with_content(
                %r{192.168.0.123:smtp      inet  n       -       n       -       -       smtpd}
              ).with_content(
                %r{10.0.0.123:smtp      inet  n       -       n       -       -       smtpd}
              )
            end
          end
          context 'when specifying multiple smtp_listen addresses as array' do
            let(:params) { { smtp_listen: ['192.168.0.123', '10.0.0.123'] } }

            it 'updates master.cf with multiple smtp listeners' do
              is_expected.to contain_file(postfix_master_cf_path).with_content(
                %r{192.168.0.123:smtp      inet  n       -       n       -       -       smtpd}
              ).with_content(
                %r{10.0.0.123:smtp      inet  n       -       n       -       -       smtpd}
              )
            end
          end
          context 'when use_amavisd is true' do
+3 −1
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@
<% elsif @smtp_listen == 'all' -%>
smtp      inet  n       -       <%= @jail %>       -       -       smtpd
<% else -%>
<%= @smtp_listen %>:smtp      inet  n       -       <%= @jail %>       -       -       smtpd
  <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%>
<%= listen_address %>:smtp      inet  n       -       <%= @jail %>       -       -       smtpd
  <%- end -%>
<% end -%>
<% if @master_submission -%>
<%= @master_submission %>
+3 −1
Original line number Diff line number Diff line
@@ -12,7 +12,9 @@
<% if @smtp_listen == 'all' -%>
smtp      inet  n       -       <%= @jail %>       -       -       smtpd
<% else -%>
<%= @smtp_listen %>:smtp      inet  n       -       <%= @jail %>       -       -       smtpd
  <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%>
<%= listen_address %>:smtp      inet  n       -       <%= @jail %>       -       -       smtpd
  <%- end -%>
<% end -%>
#smtp      inet  n       -       n       -       -       smtpd
#submission inet n      -       n       -       -       smtpd                                                                                                                                                                                
Loading