-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Declare sysadmins alias via the Foreman ENC's owner field
In the Foreman ENC there's a list of owners. This includes a mail field which can be used.
- Loading branch information
Showing
4 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# @summary Ensure root email is delivered | ||
# | ||
# If foreman_users is set via the ENC then that's used. Otherwise it ends up in | ||
# /dev/null. | ||
class profiles::base::sysadmins { | ||
# Via the Foreman ENC | ||
if defined('$foreman_users') { | ||
# lint:ignore:variable_scope | ||
$sysadmins = $foreman_users.map |$username, $user| { $user['mail'] } | ||
# lint:endignore | ||
} else { | ||
$sysadmins = ['/dev/null'] | ||
} | ||
|
||
mailalias { 'sysadmins': | ||
ensure => present, | ||
recipient => $sysadmins, | ||
} | ||
|
||
mailalias { 'root': | ||
ensure => present, | ||
recipient => 'sysadmins', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper' | ||
|
||
describe 'profiles::base::sysadmins' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'without ENC' do | ||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_mailalias('sysadmins').with_recipient(['/dev/null']) } | ||
end | ||
|
||
context 'with ENC' do | ||
# The ENC parameters aren't really `facts`. | ||
# In reality they wouldn't appear in the `$facts` hash, but with | ||
# rspec-puppet `let :facts` is still needed to set them as | ||
# top-scope variables. | ||
let(:facts) do | ||
super().merge( | ||
foreman_users: { | ||
my_username: { | ||
mail: '[email protected]', | ||
}, | ||
other: { | ||
mail: '[email protected]', | ||
}, | ||
} | ||
) | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_mailalias('sysadmins').with_recipient(['[email protected]', '[email protected]']) } | ||
end | ||
end | ||
end | ||
end |