Skip to content

Commit

Permalink
(#1) Allow users to add aliases via hieradata (#79)
Browse files Browse the repository at this point in the history
Co-authored-by: op-ct <chris.tessmer@onyxpoint.com>
  • Loading branch information
michael-riddle and op-ct authored Aug 6, 2022
1 parent a26dc1a commit 36fba1b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Tue Aug 02 2022 Mike Riddle <mike@sicura.us> - 5.7.0
- Added the ability for users to specify aliases via hieradata

* Wed Jun 16 2021 Chris Tessmer <chris.tessmer@onyxpoint.com> - 5.6.0
- Removed support for Puppet 5
- Ensured support for Puppet 7 in requirements and stdlib
Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ postfix::main_cf_hash:
- 'permit_mynetworks'
- 'reject'

postfix::aliases: {}
17 changes: 16 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@
# @param inet_protocols
# The protocols to use when enabling the service
#
# @param aliases
# Hash of alias key/value pairs that can be set in hieradata
# Example:
# ---
# postfix::aliases:
# 'root': 'system.administrator@mail.mil'
# 'foo.bar': 'fbar, fbar@example.com'
#
# @author https://github.com/simp/pupmod-simp-postfix/graphs/contributors
#
class postfix (
Hash $main_cf_hash, # Set in module data
Boolean $enable_server = false,
String $postfix_ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
String $mutt_ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
Postfix::InetProtocols $inet_protocols = fact('ipv6_enabled') ? { true => ['all'], default => ['ipv4'] }
Postfix::InetProtocols $inet_protocols = fact('ipv6_enabled') ? { true => ['all'], default => ['ipv4'] },
Optional[Hash] $aliases,
) {

include 'postfix::install'
Expand All @@ -45,4 +54,10 @@
~> Class['postfix::service']
}

$aliases.each | $key, $value| {
postfix::alias { $key:
values => $value,
}
}

}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-postfix",
"version": "5.6.0",
"version": "5.7.0",
"author": "SIMP Team",
"summary": "Manages the Postfix mail server",
"license": "Apache-2.0",
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
it { is_expected.to compile.with_all_deps }
it {is_expected.to create_class('postfix::server').that_notifies('Class[postfix::service]') }
end

context 'with aliases defined' do
let(:params) {{ :aliases => {
'root' => 'system.administrator@mail.mil',
'foo.bar' => 'fbar, fbar@example.com'
} }}
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_concat__fragment("postfix+root.alias").with({
'content' => "root: system.administrator@mail.mil\n"
})
end
it do
is_expected.to contain_concat__fragment("postfix+foo.bar.alias").with({
'content' => "foo.bar: fbar, fbar@example.com\n"
})
end
end
end
end
end
Expand Down

0 comments on commit 36fba1b

Please sign in to comment.