From 859922935747f392e1ab7997c74c15e852a201ba Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Mon, 14 Mar 2022 17:51:17 +0100 Subject: [PATCH 1/8] Support Debian 11 --- manifests/repository.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/repository.pp b/manifests/repository.pp index 8750f55..a4c97d4 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -120,7 +120,7 @@ } $location = "${url}xUbuntu_${osrelease}" } else { - if $osmajrelease == '10' { + if $osmajrelease >= '10' { $location = "${url}Debian_${osmajrelease}" } else { $location = "${url}Debian_${osmajrelease}.0" From 854346044fcf0c03ced3eb248575fbbc13a1dc19 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Mon, 14 Mar 2022 18:02:54 +0100 Subject: [PATCH 2/8] Use versioncmp instead of >= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Romain Tartière --- manifests/repository.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/repository.pp b/manifests/repository.pp index a4c97d4..5da72cd 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -120,7 +120,7 @@ } $location = "${url}xUbuntu_${osrelease}" } else { - if $osmajrelease >= '10' { + if versioncmp($osmajrelease, '10') >= 0 { $location = "${url}Debian_${osmajrelease}" } else { $location = "${url}Debian_${osmajrelease}.0" From dad103b5d72b266813adef5ef3ec1507c8bdf9a0 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Mon, 14 Mar 2022 18:28:27 +0100 Subject: [PATCH 3/8] add debian version and bareos version compatibility check --- manifests/repository.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/repository.pp b/manifests/repository.pp index 5da72cd..25e436f 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -121,6 +121,10 @@ $location = "${url}xUbuntu_${osrelease}" } else { if versioncmp($osmajrelease, '10') >= 0 { + if (versioncmp($release, '18.2') <= 0) + or ((versioncmp($release, '20') <= 0) and (versioncmp($osmajrelease, '11') >= 0)) { + fail("Bareos ${release} is not distributed for Debian ${osmajrelease}") + } $location = "${url}Debian_${osmajrelease}" } else { $location = "${url}Debian_${osmajrelease}.0" From 7d5719c1fec023bb1309b1658622860154ba161b Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Mon, 14 Mar 2022 18:31:14 +0100 Subject: [PATCH 4/8] Add Debian 11 compatibility mention --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 6391423..e36ca0f 100644 --- a/metadata.json +++ b/metadata.json @@ -36,7 +36,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "9", - "10" + "10", + "11" ] }, { From 16c5559560e6da077d20172210260a1f75c9c887 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Tue, 15 Mar 2022 08:52:41 +0100 Subject: [PATCH 5/8] fix unit test --- spec/classes/repository_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/classes/repository_spec.rb b/spec/classes/repository_spec.rb index 9bac150..92a79f0 100644 --- a/spec/classes/repository_spec.rb +++ b/spec/classes/repository_spec.rb @@ -9,8 +9,15 @@ end context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::repository') } + if (facts[:osfamily] == 'Debian') && (facts[:operatingsystemmajrelease] == '11') + it 'fails' do + expect { is_expected.to contain_class('bareos::repository') }. + to raise_error(Puppet::PreformattedError, %r{is not distributed for}) + end + else + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('bareos::repository') } + end end case facts[:osfamily] From 50bca892b915d9c41df83a9f22f05871c6a84c0d Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Wed, 16 Mar 2022 10:40:41 +0100 Subject: [PATCH 6/8] Fix Debian 11 unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Romain Tartière --- spec/classes/repository_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/classes/repository_spec.rb b/spec/classes/repository_spec.rb index 92a79f0..af50160 100644 --- a/spec/classes/repository_spec.rb +++ b/spec/classes/repository_spec.rb @@ -10,10 +10,7 @@ context 'with default values for all parameters' do if (facts[:osfamily] == 'Debian') && (facts[:operatingsystemmajrelease] == '11') - it 'fails' do - expect { is_expected.to contain_class('bareos::repository') }. - to raise_error(Puppet::PreformattedError, %r{is not distributed for}) - end + 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') } From 2e42adbdf3ff14d6b6416ad4b298c35984521e8e Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Wed, 16 Mar 2022 11:10:31 +0100 Subject: [PATCH 7/8] add release param depends on OS version --- manifests/init.pp | 2 +- manifests/params.pp | 16 +++++++++++ manifests/repository.pp | 4 +-- spec/classes/repository_spec.rb | 50 ++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 22 deletions(-) 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..ea9bb6d 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 From cbb7ca52add865df094c4700d89fb1d4225ce861 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Wed, 16 Mar 2022 22:03:32 +0100 Subject: [PATCH 8/8] add compatibility of Debian 11 with Bareos 20 --- manifests/params.pp | 17 +---------------- manifests/repository.pp | 2 +- spec/classes/repository_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index ea9bb6d..39b1358 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,22 +7,7 @@ $file_group = 'bareos' $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' - } - } + $repo_release = '20' # service/package specific # bconsole diff --git a/manifests/repository.pp b/manifests/repository.pp index e665534..22d2eed 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -122,7 +122,7 @@ } else { if versioncmp($osmajrelease, '10') >= 0 { if (versioncmp($release, '18.2') <= 0) - or ((versioncmp($release, '20') <= 0) and (versioncmp($osmajrelease, '11') >= 0)) { + or ((versioncmp($release, '20') < 0) and (versioncmp($osmajrelease, '11') >= 0)) { fail("Bareos ${release} is not distributed for Debian ${osmajrelease}") } $location = "${url}Debian_${osmajrelease}" diff --git a/spec/classes/repository_spec.rb b/spec/classes/repository_spec.rb index 63e5263..8f1505d 100644 --- a/spec/classes/repository_spec.rb +++ b/spec/classes/repository_spec.rb @@ -37,14 +37,14 @@ when 'Debian' case facts[:operatingsystemmajrelease] when '11' - context 'with release: "20"' do + context 'with release: "19.2"' do let(:params) do { - release: '20' + release: '19.2' } end - it { is_expected.to compile.and_raise_error(%r{Bareos 20 is not distributed for Debian 11}) } + it { is_expected.to compile.and_raise_error(%r{Bareos 19.2 is not distributed for Debian 11}) } end end when 'Ubuntu'