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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Parameters
* **aliases**: hash of aliases. Example: { 'user' => 'email' }
* **generics_domains**: list of domains to serve. Example: [ 'domain1.com', 'domain2.com' }
* **generics_table**: hash of user email addresses for multiple domains. Example: { 'user', 'email' }

* **is_relay**: bool, set to 1 if you want the server to be a relay
* **relay-domains**: list of domains to relay for. Example: { 'example.com', 'example2.co.uk' }
* **listen_ip**: Single IP address that the server should listen on. Example: 127.0.0.1

Usage
-----
Expand All @@ -48,6 +50,11 @@ Contributors
Release Notes
-------------

**0.1.3**

* Added relayer functionality
* Added listen_ip setting

**0.1.2**

* Template fix
Expand Down
46 changes: 44 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
# [*rootmail*]
# Mail address for the root user, default is undef
#
# [*mailertable*]
# Hash of domains and related mailers. Example: { 'uuhost1.my.domain' => 'suucp:uuhost1' }
#
# [*aliases*]
# Hash of aliases. Example: { 'user' => 'email' }
#
Expand All @@ -43,6 +46,15 @@
# [*generics_table*]
# Hash of user email addresses for multiple domains. Example: { 'user', 'email' }
#
# [*listen_ip*]
# Specifies if sendmail should listen on an ip other than localhost. Example: 127.0.0.1
#
# [*is_relay*]
# Specifies if sendmail should relay email from other servers. Boolean
#
# [*relay_domains*]
# List of domains to relay email for. Example: ['example.com','example2.co.uk']
#
# === Examples
#
# class { sendmail:
Expand All @@ -66,9 +78,13 @@
$masquerade_entire_domain = false,
$masquerade_domain = false,
$rootmail = undef,
$mailertable = undef,
$aliases = undef,
$generics_domains = undef,
$generics_table = undef,
$listen_ip = '127.0.0.1',
$is_relay = undef,
$relay_domains = $sendmail::params::relay_domains
) inherits sendmail::params {
package { $sendmail::params::sendmail_pkgs: ensure => latest }

Expand All @@ -78,9 +94,22 @@
mode => '0644',
content => template($sendmail::params::sendmail_mc_tmpl),
require => Package[$sendmail::params::sendmail_pkgs],
notify => Exec ["make_sendmail_config"],
notify => Exec["make_sendmail_config"],
}

if ($mailertable) {
file { $sendmail::params::mailertable_path:
owner => 'root',
group => 'root',
mode => '0644',
content => template($sendmail::params::mailertable_tmpl),
require => Package[$sendmail::params::sendmail_pkgs],
notify => Service[$sendmail::service_name],
}
} else {
file { $sendmail::params::mailertable_path: ensure => absent, notify => Service[$sendmail::service_name] }
}

if ($aliases) {
file { $sendmail::params::aliases_path:
owner => 'root',
Expand All @@ -93,7 +122,20 @@
} else {
file { $sendmail::params::aliases_path: ensure => absent, notify => Service[$sendmail::service_name] }
}


if ($is_relay) {
file { $sendmail::params::relay_domains_path:
owner => 'root',
group => 'root',
mode => '0644',
content => template($sendmail::params::relay_domains_tmpl),
require => Package[$sendmail::params::sendmail_pkgs],
notify => Service[$sendmail::service_name],
}
} else {
file { $sendmail::params::relay_domains_path: ensure => absent, notify => Service[$sendmail::service_name] }
}

if ($generics_domains) {
file { $sendmail::params::generics_domains_path:
owner => 'root',
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
$sendmail_pkgs = ['sendmail', 'sendmail-cf']
$sendmail_mc_path = '/etc/mail/sendmail.mc'
$sendmail_mc_tmpl = 'sendmail/sendmail.mc.erb'
$mailertable_path = '/etc/mail/mailertable'
$mailertable_tmpl = 'sendmail/mailertable.erb'
$aliases_path = '/etc/mail/aliases'
$aliases_tmpl = 'sendmail/aliases.erb'
$relay_domains_path = '/etc/mail/relay-domains'
$relay_domains_tmpl = 'sendmail/relay-domains.erb'
$is_relay = 'sendmail/relay-domains.erb'
$relay_domains = ['example.com', 'example.co.uk']
$generics_domains_path = '/etc/mail/generics-domains'
$generics_domains_tmpl = 'sendmail/generics-domains.erb'
$generics_table_path = '/etc/mail/genericstable'
$generics_table_tmpl = 'sendmail/genericstable.erb'
$service_name = 'sendmail'
$listen_ip = '127.0.0.1'
}
3 changes: 3 additions & 0 deletions templates/mailertable.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% scope.lookupvar('sendmail::mailertable').sort.each do |domain,mailer| -%>
<%= domain %> <%= mailer %>
<% end -%>
3 changes: 3 additions & 0 deletions templates/relay-domains.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% scope.lookupvar('sendmail::relay_domains').each do |relaydomain| -%>
<%= relaydomain %>
<% end -%>
4 changes: 2 additions & 2 deletions templates/sendmail.mc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=<%= scope.lookupvar('sendmail::listen_ip') %>, Name=MTA')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 587 for
dnl # mail from MUAs that authenticate. Roaming users who can't reach their
Expand Down Expand Up @@ -199,4 +199,4 @@ dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
<% end -%>
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
dnl MAILER(cyrusv2)dnl