From 516cbcb223c14159b525772853f17c1c7f24c5c8 Mon Sep 17 00:00:00 2001 From: "Georges M. Zwingelstein" Date: Tue, 21 Nov 2023 09:59:04 -0500 Subject: [PATCH 1/4] Fix RedHat urls --- manifests/repo.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index 34431b8..e059820 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -54,8 +54,8 @@ } } 'RedHat': { - $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_${fact('os.release.major')}/" - $crio_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/CentOS_${fact('os.release.major')}/" + $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_${fact('os.release.major')}_Stream/" + $crio_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/CentOS_${fact('os.release.major')}_Stream/" yumrepo { 'libcontainers:stable': descr => 'Stable releases of libcontainers', From 8790bfa981f7f1beae6cffe26579788acb2e03c4 Mon Sep 17 00:00:00 2001 From: "Georges M. Zwingelstein" Date: Tue, 21 Nov 2023 22:19:45 -0500 Subject: [PATCH 2/4] Address review comment --- manifests/repo.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index e059820..ef9e338 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -54,8 +54,9 @@ } } 'RedHat': { - $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_${fact('os.release.major')}_Stream/" - $crio_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/CentOS_${fact('os.release.major')}_Stream/" + $release_name = if fact('os.release.major') > 7 { "CentOS_${fact('os.release.major')}_Stream" } else { "CentOS_${fact('os.release.major')}" } + $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${release_name}/" + $crio_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/${release_name}/" yumrepo { 'libcontainers:stable': descr => 'Stable releases of libcontainers', From 9179183d80001ba1c69924ad30c05d17ce1a9476 Mon Sep 17 00:00:00 2001 From: GeorgesZ Date: Wed, 22 Nov 2023 07:35:23 -0500 Subject: [PATCH 3/4] Use versioncmp --- manifests/repo.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index ef9e338..bbd5b4c 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -54,7 +54,7 @@ } } 'RedHat': { - $release_name = if fact('os.release.major') > 7 { "CentOS_${fact('os.release.major')}_Stream" } else { "CentOS_${fact('os.release.major')}" } + $release_name = if versioncmp(fact('os.release.major'), '7') == 1 { "CentOS_${fact('os.release.major')}_Stream" } else { "CentOS_${fact('os.release.major')}" } $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${release_name}/" $crio_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/${release_name}/" From 0466247560e54844c7875644b4e999f88839faca Mon Sep 17 00:00:00 2001 From: GeorgesZ Date: Wed, 22 Nov 2023 16:49:41 -0500 Subject: [PATCH 4/4] Add unit test for RedHat yum repo --- spec/classes/repo_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 9009f34..7bbb80b 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -17,5 +17,17 @@ class { '::k8s': it { is_expected.to compile } end + context 'on RedHat/CentOS 7, 8 and 9' do + let(:facts) { os_facts } + if os['family'] == 'RedHat' and os['release']['major'] == '7' + it { is_expected.to contain_yumrepo('libcontainers:stable').with_baseurl => 'https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_7/'} + end + if os['family'] == 'RedHat' and os['release']['major'] == '8' + it { is_expected.to contain_yumrepo('libcontainers:stable').with_baseurl => 'https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8_Stream/'} + end + if os['family'] == 'RedHat' and os['release']['major'] == '9' + it { is_expected.to contain_yumrepo('libcontainers:stable').with_baseurl => 'https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_9_Stream/'} + end + end end end