Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ _ReSharper*/
.vagrant/
pkg/
*~
/.idea/
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class {'postfix':
* `relayhost_port` This sets the port for the relay host specified with the `relayhost` parameter. The default is `undef` which leaves the port specifier off the end of the relayhost setting. This parameter does nothing if the `relayhost` parameter is not set.
* `daemon_directory` Sets the directory with Postfix support programs and daemon programs are installed. The default is specific for each operating system. It's _not_ recommended that this parameter be changed.
* `inet_interfaces` Sets the network interface for postfix to bind do. The default value is `localhost`
* `inet_protocols` The Internet protocols Postfix will attempt to use when making or accepting connections. Specify one or more of "ipv4" or "ipv6", separated by whitespace or commas. The default value is `all`

# Attribution

Expand Down
17 changes: 17 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
$relayhost_port = undef,
$daemon_directory = $::postfix::params::daemon_directory,
$inet_interfaces = $::postfix::params::inet_interfaces,
$inet_protocols = $::postfix::params::inet_protocols,
$masquerade_domains = $facts['networking']['fqdn'],
$virtual_root = false,
) inherits postfix::params {

if $remove_sendmail {
Expand Down Expand Up @@ -75,4 +78,18 @@
]
}

if $virtual_root {
file { '/etc/postfix/virtual':
ensure => present,
content => 'root root@localhost',
require => Package['postfix']
}

exec { 'rebuild.virtual.db':
command => '/sbin/postmap /etc/postfix/virtual',
subscribe => File['/etc/postfix/virtual'],
refreshonly => true,
notify => Service['postfix']
}
}
}
7 changes: 4 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# [Remember: No empty lines between comments and class definition]
class postfix::params{
# Set OS family specific variables here, and test for supported OS families.
case $::osfamily{
case $facts['os']['family']{
/Debian/: {
$sendmail_ensure = 'purged'
$package = 'postfix'
Expand All @@ -39,13 +39,14 @@
$daemon_directory = '/usr/libexec/postfix'
}
default: {
fail("The postfix module does not support the ${::osfamily} family of operating systems.")
fail("The postfix module does not support the ${facts['os']['family']} family of operating systems.")
}
}

# Set OS independent varibles here
$sendmail_package = 'sendmail'
$sendmailcf_package = 'sendmail-cf'
$sendmail_service = 'sendmail'
$inet_interfaces = 'localhost'
$inet_protocols = 'all'
}
11 changes: 10 additions & 1 deletion spec/classes/postfix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
%r{^myorigin = }
) }
it { should contain_file('postfix_config').with_content(
%r{^mydestination = \$myhostname, localhost.\$mydomain, localhost$}
%r{^mydestination = $myhostname, localhost.$mydomain, localhost$}
) }
it { should contain_file('postfix_config').without_content(
%r{^relayhost =}
Expand Down Expand Up @@ -98,6 +98,15 @@
) }
end

describe 'when setting inet_protocols' do
let :params do
{ :inet_protocols => 'all' }
end
it { should contain_file('postfix_config').with_content(
%r{^inet_protocols = all$}
) }
end

end
end

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
'sendmail_package' => 'sendmail',
'sendmailcf_package' => 'sendmail-cf',
'sendmail_service' => 'sendmail',
'inet_interfaces' => 'localhost'
'inet_interfaces' => 'localhost',
'inet_protocols' => 'all'
}
case os['osfamily']
when 'Debian'
Expand Down
25 changes: 18 additions & 7 deletions templates/main.cf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ myorigin = <%= @myorigin %>
inet_interfaces = <%= @inet_interfaces %>

# Enable IPv4, and IPv6 if supported
inet_protocols = all
inet_protocols = <%= @inet_protocols %>

# The proxy_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on by way of a
Expand Down Expand Up @@ -166,14 +166,14 @@ inet_protocols = all
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
<%- if @mydestination -%>
mydestination = <%= @mydestination %>
<%- else -%>
mydestination = $myhostname, localhost.$mydomain, localhost
<%- end -%>
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain

# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
Expand Down Expand Up @@ -478,6 +478,8 @@ alias_database = hash:/etc/aliases
# the main.cf file, otherwise the SMTP server will reject mail for
# non-UNIX accounts with "User unknown in local recipient table".
#
# Cyrus IMAP over LMTP. Specify ``lmtpunix cmd="lmtpd"
# listen="/var/imap/socket/lmtp" prefork=0'' in cyrus.conf.
#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp

# If using the cyrus-imapd IMAP server deliver local mail to the IMAP
Expand All @@ -500,7 +502,8 @@ alias_database = hash:/etc/aliases
# how many simultaneous LMTP sessions will be permitted to the Cyrus
# message store.
#
# To use the old cyrus deliver program you have to set:
# Cyrus IMAP via command line. Uncomment the "cyrus...pipe" and
# subsequent line in master.cf.
#mailbox_transport = cyrus

# The fallback_transport specifies the optional transport in master.cf
Expand Down Expand Up @@ -685,8 +688,16 @@ manpage_directory = /usr/share/man
# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sample_directory = /usr/share/doc/postfix-2.10.1/samples

# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

# smtpd_forbid_bare_newline: disallow bare newline
#
#smtpd_forbid_bare_newline = yes
#smtpd_forbid_bare_newline_exclusions = $mynetworks

masquerade_domains = <%= @masquerade_domains %>

4 changes: 2 additions & 2 deletions tests/set_relayport.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class{'postfix':
relayhost => 'smtp.example.org',
relayhost_port => '999',
relayhost => 'smtp.example.org',
relayhost_port => '999',
}