Commit 06a380cf authored by Cory Ringdahl's avatar Cory Ringdahl
Browse files

allow hiera driven transport/virtual/hash/conffile

parent b3cb2e70
......@@ -50,6 +50,4 @@ define postfix::hash (
path => $name,
mode => $mode,
}
Class['postfix'] -> Postfix::Hash[$title]
}
......@@ -10,6 +10,14 @@
#
# [*configs*] - (hash)
#
# [*hash*] - (hash) A hash of postfix::hash resources
#
# [*transport*] - (hash) A hash of postfix::transport resources
#
# [*virtual*] - (hash) A hash of postfix::virtual resources
#
# [*conffile*] - (hash) A hash of postfix::conffile resources
#
# [*amavis_procs*] - (integer) Number of amavis scanners to spawn
#
# [*inet_interfaces*] - (string)
......@@ -97,6 +105,10 @@ class postfix (
String $root_group = 'root',
String $alias_maps = 'hash:/etc/aliases',
Optional[Hash] $configs = {},
Optional[Hash] $hash = {},
Optional[Hash] $transport = {},
Optional[Hash] $virtual = {},
Optional[Hash] $conffile = {},
Integer $amavis_procs = 2,
String $inet_interfaces = 'all',
String $inet_protocols = 'all',
......@@ -158,6 +170,10 @@ class postfix (
}
create_resources('::postfix::config', $configs)
create_resources('::postfix::transport', $transport)
create_resources('::postfix::virtual', $virtual)
create_resources('::postfix::hash', $hash)
create_resources('::postfix::conffile', $conffile)
anchor { 'postfix::begin': }
-> class { '::postfix::packages': }
......
......@@ -480,6 +480,86 @@ describe 'postfix' do
is_expected.to contain_postfix__config('message_size_limit').with_value('51200000')
end
end
context 'when hash hash is used' do
let(:params) do
{
hash: {
'/etc/postfix/transport' => {
'ensure' => 'present',
},
},
}
end
it 'updates master.cf with the specified contents' do
is_expected.to contain_postfix__hash('/etc/postfix/transport').with_ensure('present')
end
end
context 'when transport hash is used' do
let(:params) do
{
transport: {
'local_relay' => {
'nexthop' => '[10.12.0.2]:9925',
},
},
}
end
it 'updates master.cf with the specified contents' do
is_expected.to contain_postfix__transport('local_relay').with_nexthop('[10.12.0.2]:9925')
end
end
context 'when virtual hash is used' do
let(:params) do
{
virtual: {
'someone@somedomain.tld' => {
'destination' => 'internal@ourdomain.tld',
},
},
}
end
it 'updates master.cf with the specified contents' do
is_expected.to contain_postfix__virtual('someone@somedomain.tld').with_destination('internal@ourdomain.tld')
end
end
context 'when conffile hash is used' do
let(:params) do
{
conffile: {
'ldapoptions.cf' => {
'mode' => '0640',
'options' => {
'server_host' => 'ldap.mydomain.com',
'bind' => 'yes',
'bind_dn' => 'cn=admin,dc=mydomain,dc=com',
'bind_pw' => 'password',
'search_base' => 'dc=example, dc=com',
'query_filter' => 'mail=%s',
'result_attribute' => 'uid',
},
},
},
}
end
it 'creates ldapoptions.cf with the specified contents' do
is_expected.to contain_postfix__conffile('ldapoptions.cf').with(
'mode' => '0640',
'options' => {
'server_host' => 'ldap.mydomain.com',
'bind' => 'yes',
'bind_dn' => 'cn=admin,dc=mydomain,dc=com',
'bind_pw' => 'password',
'search_base' => 'dc=example, dc=com',
'query_filter' => 'mail=%s',
'result_attribute' => 'uid',
}
)
end
end
end
end
end
......
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