Skip to content

Commit

Permalink
add release param depends on OS version
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentPoinsaut committed Mar 16, 2022
1 parent 50bca89 commit d439141
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$file_group = $bareos::params::file_group,
$file_mode = $bareos::params::file_mode,
$file_dir_mode = $bareos::params::file_dir_mode,
String $repo_release = '20',
String $repo_release = $bareos::params::repo_release,
Boolean $repo_subscription = false,
Optional[String[1]] $repo_username = undef,
Optional[String[1]] $repo_password = undef,
Expand Down
16 changes: 16 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
$config_dir = '/etc/bareos'
$config_dir_webui = '/etc/bareos-webui'

case $facts['os']['name'] {
'Debian': {
case $facts['os']['release']['major'] {
'11': {
$repo_release = '21'
}
default: {
$repo_release = '20'
}
}
}
default: {
$repo_release = '20'
}
}

# service/package specific
# bconsole
$console_package_name = 'bareos-bconsole'
Expand Down
4 changes: 2 additions & 2 deletions manifests/repository.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
# The major bareos release version which should be used
#
class bareos::repository (
Enum['18.2', '19.2', '20', '21'] $release = '20',
Enum['18.2', '19.2', '20', '21'] $release = $bareos::params::repo_release,
Optional[String[1]] $gpg_key_fingerprint = undef,
Boolean $subscription = false,
Optional[String] $username = undef,
Optional[String] $password = undef,
) {
) inherits bareos::params {
$scheme = 'http://'
if $subscription {
if empty($username) or empty($password) {
Expand Down
50 changes: 31 additions & 19 deletions spec/classes/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
end

context 'with default values for all parameters' do
if (facts[:osfamily] == 'Debian') && (facts[:operatingsystemmajrelease] == '11')
it { is_expected.to compile.and_raise_error(%r{is not distributed for}) }
else
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('bareos::repository') }
end
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('bareos::repository') }
end

case facts[:osfamily]
Expand All @@ -37,22 +33,38 @@
end
end
when 'Debian'
case facts[:operatingsystemmajrelease]
when '20'
context 'with subscription: true, username: "test", password: "test"' do
let(:params) do
{
subscription: true,
username: 'test',
password: 'test'
}
case facts[:operatingsystem]
when 'Debian'
case facts[:operatingsystemmajrelease]
when '11'
context 'with release: "20"' do
let(:params) do
{
release: '20'
}
end

it { is_expected.to compile.and_raise_error(%r{Bareos 20 is not distributed for Debian 11}) }
end
end
when 'Ubuntu'
case facts[:operatingsystemmajrelease]
when '20'
context 'with subscription: true, username: "test", password: "test"' do
let(:params) do
{
subscription: true,
username: 'test',
password: 'test'
}
end

it { is_expected.to compile }
it { is_expected.to compile }

it do
expect(subject).to contain_apt__source('bareos').
with_location('http://test:test@download.bareos.com/bareos/release/latest/xUbuntu_20.04')
it do
expect(subject).to contain_apt__source('bareos').
with_location('http://test:test@download.bareos.com/bareos/release/latest/xUbuntu_20.04')
end
end
end
end
Expand Down

0 comments on commit d439141

Please sign in to comment.