Skip to content

Commit 2e42adb

Browse files
add release param depends on OS version
1 parent 50bca89 commit 2e42adb

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$file_group = $bareos::params::file_group,
3939
$file_mode = $bareos::params::file_mode,
4040
$file_dir_mode = $bareos::params::file_dir_mode,
41-
String $repo_release = '20',
41+
String $repo_release = $bareos::params::repo_release,
4242
Boolean $repo_subscription = false,
4343
Optional[String[1]] $repo_username = undef,
4444
Optional[String[1]] $repo_password = undef,

manifests/params.pp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
$config_dir = '/etc/bareos'
99
$config_dir_webui = '/etc/bareos-webui'
1010

11+
case $facts['os']['name'] {
12+
'Debian': {
13+
case $facts['os']['release']['major'] {
14+
'11': {
15+
$repo_release = '21'
16+
}
17+
default: {
18+
$repo_release = '20'
19+
}
20+
}
21+
}
22+
default: {
23+
$repo_release = '20'
24+
}
25+
}
26+
1127
# service/package specific
1228
# bconsole
1329
$console_package_name = 'bareos-bconsole'

manifests/repository.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
# The major bareos release version which should be used
2020
#
2121
class bareos::repository (
22-
Enum['18.2', '19.2', '20', '21'] $release = '20',
22+
Enum['18.2', '19.2', '20', '21'] $release = $bareos::params::repo_release,
2323
Optional[String[1]] $gpg_key_fingerprint = undef,
2424
Boolean $subscription = false,
2525
Optional[String] $username = undef,
2626
Optional[String] $password = undef,
27-
) {
27+
) inherits bareos::params {
2828
$scheme = 'http://'
2929
if $subscription {
3030
if empty($username) or empty($password) {

spec/classes/repository_spec.rb

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
end
1010

1111
context 'with default values for all parameters' do
12-
if (facts[:osfamily] == 'Debian') && (facts[:operatingsystemmajrelease] == '11')
13-
it { is_expected.to compile.and_raise_error(%r{is not distributed for}) }
14-
else
15-
it { is_expected.to compile.with_all_deps }
16-
it { is_expected.to contain_class('bareos::repository') }
17-
end
12+
it { is_expected.to compile.with_all_deps }
13+
it { is_expected.to contain_class('bareos::repository') }
1814
end
1915

2016
case facts[:osfamily]
@@ -37,22 +33,38 @@
3733
end
3834
end
3935
when 'Debian'
40-
case facts[:operatingsystemmajrelease]
41-
when '20'
42-
context 'with subscription: true, username: "test", password: "test"' do
43-
let(:params) do
44-
{
45-
subscription: true,
46-
username: 'test',
47-
password: 'test'
48-
}
36+
case facts[:operatingsystem]
37+
when 'Debian'
38+
case facts[:operatingsystemmajrelease]
39+
when '11'
40+
context 'with release: "20"' do
41+
let(:params) do
42+
{
43+
release: '20'
44+
}
45+
end
46+
47+
it { is_expected.to compile.and_raise_error(%r{Bareos 20 is not distributed for Debian 11}) }
4948
end
49+
end
50+
when 'Ubuntu'
51+
case facts[:operatingsystemmajrelease]
52+
when '20'
53+
context 'with subscription: true, username: "test", password: "test"' do
54+
let(:params) do
55+
{
56+
subscription: true,
57+
username: 'test',
58+
password: 'test'
59+
}
60+
end
5061

51-
it { is_expected.to compile }
62+
it { is_expected.to compile }
5263

53-
it do
54-
expect(subject).to contain_apt__source('bareos').
55-
with_location('http://test:[email protected]/bareos/release/latest/xUbuntu_20.04')
64+
it do
65+
expect(subject).to contain_apt__source('bareos').
66+
with_location('http://test:[email protected]/bareos/release/latest/xUbuntu_20.04')
67+
end
5668
end
5769
end
5870
end

0 commit comments

Comments
 (0)