From 73bdbe0735184d67e2788a0137e2bda13d3b7180 Mon Sep 17 00:00:00 2001 From: Craig Reeves Date: Tue, 31 Mar 2015 09:48:39 +0100 Subject: [PATCH 1/2] Added relay for domains setting Added listen_ip setting Fixed typo --- README.md | 9 ++++++++- manifests/init.pp | 29 +++++++++++++++++++++++++++-- manifests/params.pp | 5 +++++ templates/relay-domains.erb | 3 +++ templates/sendmail.mc.erb | 4 ++-- 5 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 templates/relay-domains.erb diff --git a/README.md b/README.md index 43cc727..9dc1682 100644 --- a/README.md +++ b/README.md @@ -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 ----- @@ -48,6 +50,11 @@ Contributors Release Notes ------------- +**0.1.3** + +* Added relayer functionality +* Added listen_ip setting + **0.1.2** * Template fix diff --git a/manifests/init.pp b/manifests/init.pp index 09149c4..47950cd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,6 +43,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: @@ -69,6 +78,9 @@ $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 } @@ -78,7 +90,7 @@ 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 ($aliases) { @@ -93,7 +105,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', diff --git a/manifests/params.pp b/manifests/params.pp index 489a1a1..0a81f5b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,9 +4,14 @@ $sendmail_mc_tmpl = 'sendmail/sendmail.mc.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' } diff --git a/templates/relay-domains.erb b/templates/relay-domains.erb new file mode 100644 index 0000000..9913321 --- /dev/null +++ b/templates/relay-domains.erb @@ -0,0 +1,3 @@ +<% scope.lookupvar('sendmail::relay_domains').each do |relaydomain| -%> +<%= relaydomain %> +<% end -%> \ No newline at end of file diff --git a/templates/sendmail.mc.erb b/templates/sendmail.mc.erb index 845cb49..549e93a 100644 --- a/templates/sendmail.mc.erb +++ b/templates/sendmail.mc.erb @@ -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 @@ -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 \ No newline at end of file From 3b455910860b22c6413f913112766afa1a25e63f Mon Sep 17 00:00:00 2001 From: Ugo Paternostro Date: Sat, 17 Oct 2015 20:01:38 +0200 Subject: [PATCH 2/2] Adding support for mailertable --- manifests/init.pp | 17 +++++++++++++++++ manifests/params.pp | 2 ++ templates/mailertable.erb | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 templates/mailertable.erb diff --git a/manifests/init.pp b/manifests/init.pp index 47950cd..2aee63a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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' } # @@ -75,6 +78,7 @@ $masquerade_entire_domain = false, $masquerade_domain = false, $rootmail = undef, + $mailertable = undef, $aliases = undef, $generics_domains = undef, $generics_table = undef, @@ -93,6 +97,19 @@ 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', diff --git a/manifests/params.pp b/manifests/params.pp index 0a81f5b..8c9f09c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,6 +2,8 @@ $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' diff --git a/templates/mailertable.erb b/templates/mailertable.erb new file mode 100644 index 0000000..6f99a37 --- /dev/null +++ b/templates/mailertable.erb @@ -0,0 +1,3 @@ +<% scope.lookupvar('sendmail::mailertable').sort.each do |domain,mailer| -%> +<%= domain %> <%= mailer %> +<% end -%>