diff --git a/manifests/init.pp b/manifests/init.pp index dd85ab2..f7ec3dc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, diff --git a/manifests/params.pp b/manifests/params.pp index b8175e2..44c39c2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' diff --git a/manifests/repository.pp b/manifests/repository.pp index 25e436f..e665534 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -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) { diff --git a/spec/classes/repository_spec.rb b/spec/classes/repository_spec.rb index af50160..63e5263 100644 --- a/spec/classes/repository_spec.rb +++ b/spec/classes/repository_spec.rb @@ -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] @@ -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