Skip to content
Snippets Groups Projects
Unverified Commit 1cdc9ac2 authored by Romain Tartière's avatar Romain Tartière Committed by GitHub
Browse files

Merge pull request #326 from jcpunk/masqurade

Add switches for simple domain masquerade
parents d73f04db f3978930
No related branches found
No related tags found
No related merge requests found
...@@ -117,6 +117,22 @@ A Boolean defining whether the puppet module should manage the mailx package. Se ...@@ -117,6 +117,22 @@ A Boolean defining whether the puppet module should manage the mailx package. Se
Default: true. Default: true.
##### `masquerade_classes`
An array defining the masquerade_classes to use.
Default: Undefined.
Example: ['envelope_sender', 'envelope_recipient', 'header_sender', 'header_recipient']
##### `masquerade_domains`
An array defining the masquerade_domains to use.
The order of elements matters here, so be aware of how you define the elements.
Default: Undefined.
Example: ['foo.example.com', 'example.com']
##### `masquerade_exceptions`
An array defining the masquerade_exceptions to use.
Default: Undefined.
Example: ['root']
##### `mastercf_source` ##### `mastercf_source`
A string defining the location of a skeleton master.cf file to be used. A string defining the location of a skeleton master.cf file to be used.
Default: Undefined. Default: Undefined.
......
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
# #
# [*manage_mailx*] - (boolean) Whether to manage mailx package. # [*manage_mailx*] - (boolean) Whether to manage mailx package.
# #
# [*masquerade_classes*] - (array)
#
# [*masquerade_domains*] - (array)
#
# [*masquerade_exceptions*] - (array)
#
# [*mastercf_source*] - (string) # [*mastercf_source*] - (string)
# #
# [*mastercf_content*] - (string) # [*mastercf_content*] - (string)
...@@ -127,6 +133,9 @@ class postfix ( ...@@ -127,6 +133,9 @@ class postfix (
Boolean $manage_conffiles = true, Boolean $manage_conffiles = true,
Boolean $manage_mailname = true, Boolean $manage_mailname = true,
Boolean $manage_mailx = true, Boolean $manage_mailx = true,
Optional[Array[String[1]]] $masquerade_classes = undef,
Optional[Array[String[1]]] $masquerade_domains = undef,
Optional[Array[String[1]]] $masquerade_exceptions = undef,
Optional[String] $mastercf_source = undef, Optional[String] $mastercf_source = undef,
Optional[String] $mastercf_content = undef, Optional[String] $mastercf_content = undef,
Optional[String] $mastercf_template = undef, Optional[String] $mastercf_template = undef,
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
# directly without a relay. # directly without a relay.
# [*mydestination*] - (string) # [*mydestination*] - (string)
# [*mynetworks*] - (string) # [*mynetworks*] - (string)
# [*masquerade_classes*] - (array)
# [*masquerade_domains*] - (array)
# [*masquerade_exceptions*] - (array)
# #
# === Examples # === Examples
# #
...@@ -29,12 +32,18 @@ class postfix::mta ( ...@@ -29,12 +32,18 @@ class postfix::mta (
Optional[Pattern[/^\S+(?:,\s*\S+)*$/]] $mydestination = undef, Optional[Pattern[/^\S+(?:,\s*\S+)*$/]] $mydestination = undef,
Optional[Pattern[/^(?:\S+?(?:(?:,\s+)|(?:\s+))?)*$/]] $mynetworks = undef, Optional[Pattern[/^(?:\S+?(?:(?:,\s+)|(?:\s+))?)*$/]] $mynetworks = undef,
Optional[Pattern[/^\S+$/]] $relayhost = undef, Optional[Pattern[/^\S+$/]] $relayhost = undef,
Optional[Array[String[1]]] $masquerade_classes = undef,
Optional[Array[String[1]]] $masquerade_domains = undef,
Optional[Array[String[1]]] $masquerade_exceptions = undef,
) { ) {
include postfix include postfix
$_mydestination = pick($mydestination, $postfix::mydestination) $_mydestination = pick($mydestination, $postfix::mydestination)
$_mynetworks = pick($mynetworks, $postfix::mynetworks) $_mynetworks = pick($mynetworks, $postfix::mynetworks)
$_relayhost = pick($relayhost, $postfix::relayhost) $_relayhost = pick($relayhost, $postfix::relayhost)
$_masquerade_classes = pick_default($masquerade_classes, $postfix::masquerade_classes)
$_masquerade_domains = pick_default($masquerade_domains, $postfix::masquerade_domains)
$_masquerade_exceptions = pick_default($masquerade_exceptions, $postfix::masquerade_exceptions)
# If direct is specified then relayhost should be blank # If direct is specified then relayhost should be blank
if ($_relayhost == 'direct') { if ($_relayhost == 'direct') {
...@@ -56,6 +65,16 @@ class postfix::mta ( ...@@ -56,6 +65,16 @@ class postfix::mta (
'transport_maps': value => "hash:${postfix::confdir}/transport"; 'transport_maps': value => "hash:${postfix::confdir}/transport";
} }
if ! $_masquerade_classes.empty() {
postfix::config { 'masquerade_classes': value => join($_masquerade_classes, ' ') }
}
if ! $_masquerade_domains.empty() {
postfix::config { 'masquerade_domains': value => join($_masquerade_domains, ' ') }
}
if ! $_masquerade_exceptions.empty() {
postfix::config { 'masquerade_exceptions': value => join($_masquerade_exceptions, ' ') }
}
postfix::hash { "${postfix::confdir}/virtual": postfix::hash { "${postfix::confdir}/virtual":
ensure => 'present', ensure => 'present',
} }
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
# [*mydestination*] - (string) # [*mydestination*] - (string)
# [*mynetworks*] - (string) # [*mynetworks*] - (string)
# [*relayhost*] - (string) # [*relayhost*] - (string)
# [*masquerade_classes*] - (array)
# [*masquerade_domains*] - (array)
# [*masquerade_exceptions*] - (array)
# #
# === Examples # === Examples
# #
...@@ -26,6 +29,9 @@ class postfix::satellite ( ...@@ -26,6 +29,9 @@ class postfix::satellite (
$mydestination = undef, $mydestination = undef,
$mynetworks = undef, $mynetworks = undef,
$relayhost = undef, $relayhost = undef,
$masquerade_classes = undef,
$masquerade_domains = undef,
$masquerade_exceptions = undef,
) { ) {
include postfix include postfix
...@@ -34,11 +40,17 @@ class postfix::satellite ( ...@@ -34,11 +40,17 @@ class postfix::satellite (
$_mydestination = pick($mydestination, $postfix::mydestination) $_mydestination = pick($mydestination, $postfix::mydestination)
$_mynetworks = pick($mynetworks, $postfix::mynetworks) $_mynetworks = pick($mynetworks, $postfix::mynetworks)
$_relayhost = pick($relayhost, $postfix::relayhost) $_relayhost = pick($relayhost, $postfix::relayhost)
$_masquerade_classes = pick_default($masquerade_classes, $postfix::masquerade_classes)
$_masquerade_domains = pick_default($masquerade_domains, $postfix::masquerade_domains)
$_masquerade_exceptions = pick_default($masquerade_exceptions, $postfix::masquerade_exceptions)
class { 'postfix::mta': class { 'postfix::mta':
mydestination => $_mydestination, mydestination => $_mydestination,
mynetworks => $_mynetworks, mynetworks => $_mynetworks,
relayhost => $_relayhost, relayhost => $_relayhost,
masquerade_classes => $masquerade_classes,
masquerade_domains => $masquerade_domains,
masquerade_exceptions => $masquerade_exceptions,
} }
postfix::virtual { "@${postfix::myorigin}": postfix::virtual { "@${postfix::myorigin}":
......
...@@ -8,6 +8,9 @@ describe 'postfix::mta' do ...@@ -8,6 +8,9 @@ describe 'postfix::mta' do
mydestination => 'bar', mydestination => 'bar',
mynetworks => '127.0.0.1/8, [::1]/128 ![::2]/128', mynetworks => '127.0.0.1/8, [::1]/128 ![::2]/128',
relayhost => 'foo', relayhost => 'foo',
masquerade_classes => ['envelope_sender'],
masquerade_domains => ['host.example.com', 'example.com'],
masquerade_exceptions => ['root'],
}" }"
end end
...@@ -21,6 +24,9 @@ describe 'postfix::mta' do ...@@ -21,6 +24,9 @@ describe 'postfix::mta' do
it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } it { is_expected.to contain_postfix__config('mydestination').with_value('bar') }
it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') } it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') }
it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } it { is_expected.to contain_postfix__config('relayhost').with_value('foo') }
it { is_expected.to contain_postfix__config('masquerade_classes').with_value('envelope_sender') }
it { is_expected.to contain_postfix__config('masquerade_domains').with_value('host.example.com example.com') }
it { is_expected.to contain_postfix__config('masquerade_exceptions').with_value('root') }
context "when mydestination => 'blank'" do context "when mydestination => 'blank'" do
let :pre_condition do let :pre_condition do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment