Unverified Commit 4f935088 authored by Julian's avatar Julian Committed by GitHub

Feature/allow specify master cf content & template (#217)

Add possibility to specify a template for master.cf

Closes #91 
parent a3bbeb96
......@@ -8,6 +8,8 @@ class postfix::files {
$manage_conffiles = $postfix::manage_conffiles
$maincf_source = $postfix::maincf_source
$mastercf_source = $postfix::mastercf_source
$mastercf_content = $postfix::mastercf_content
$mastercf_template = $postfix::mastercf_template
$master_smtp = $postfix::master_smtp
$master_smtps = $postfix::master_smtps
$master_submission = $postfix::master_submission
......@@ -58,9 +60,13 @@ class postfix::files {
# Config files
if $mastercf_source {
$mastercf_content = undef
$_mastercf_content = undef
} elsif $mastercf_content {
$_mastercf_content = $mastercf_content
} elsif $mastercf_template {
$_mastercf_content = epp($mastercf_template)
} else {
$mastercf_content = template(
$_mastercf_content = template(
$postfix::params::master_os_template,
'postfix/master.cf.common.erb'
)
......@@ -68,7 +74,7 @@ class postfix::files {
file { '/etc/postfix/master.cf':
ensure => 'file',
content => $mastercf_content,
content => $_mastercf_content,
group => 'root',
mode => '0644',
owner => 'root',
......
......@@ -34,6 +34,10 @@
#
# [*mastercf_source*] - (string)
#
# [*mastercf_content*] - (string)
#
# [*mastercf_template*] - (string)
#
# [*master_smtp*] - (string)
#
# [*master_smtps*] - (string)
......@@ -101,6 +105,8 @@ class postfix (
Boolean $manage_conffiles = true,
Boolean $manage_mailx = true,
Optional[String] $mastercf_source = undef,
Optional[String] $mastercf_content = undef,
Optional[String] $mastercf_template = undef,
Optional[String] $master_smtp = undef, # postfix_master_smtp
Optional[String] $master_smtps = undef, # postfix_master_smtps
Optional[String] $master_submission = undef, # postfix_master_submission
......@@ -128,6 +134,13 @@ class postfix (
Boolean $service_enabled = true,
) inherits postfix::params {
if (($mastercf_source and $mastercf_content) or
($mastercf_source and $mastercf_template) or
($mastercf_content and $mastercf_template) or
($mastercf_source and $mastercf_content and $mastercf_template)){
fail('mastercf_source, mastercf_content and mastercf_template are mutually exclusive')
}
$_smtp_listen = $mailman ? {
true => '0.0.0.0',
default => $smtp_listen,
......
......@@ -221,6 +221,59 @@ describe 'postfix' do
skip 'need to write this still'
end
end
context 'when specifying a custom mastercf_content' do
let (:params) { {
:mastercf_content => 'testy'
} }
it 'should do stuff' do
skip 'need to write this still'
end
end
context 'when specifying a custom mastercf_template' do
let (:params) { {
:mastercf_template => 'testy'
} }
it 'should do stuff' do
skip 'need to write this still'
end
end
context 'when specifying a custom mastercf_source and mastercf_content' do
let (:params) { {
:mastercf_source => 'testy_1' ,
:mastercf_content => 'testy_2'
} }
it 'should fail' do
expect { should compile }.to raise_error(/mutually exclusive/)
end
end
context 'when specifying a custom mastercf_source and mastercf_template' do
let (:params) { {
:mastercf_source => 'testy_1' ,
:mastercf_template => 'testy_2'
} }
it 'should fail' do
expect { should compile }.to raise_error(/mutually exclusive/)
end
end
context 'when specifying a custom mastercf_content and mastercf_template' do
let (:params) { {
:mastercf_content => 'testy_1' ,
:mastercf_template => 'testy_2'
} }
it 'should fail' do
expect { should compile }.to raise_error(/mutually exclusive/)
end
end
context 'when specifying a mastercf_source and custom mastercf_content and mastercf_template' do
let (:params) { {
:mastercf_source => 'testy_1' ,
:mastercf_content => 'testy_2' ,
:mastercf_template => 'testy_3'
} }
it 'should fail' do
expect { should compile }.to raise_error(/mutually exclusive/)
end
end
context 'when specifying a custom master_smtp' do
let(:params) do
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment