From 21cb4535b3d16ce809a3dea42ce44309a4384de6 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 27 Jan 2022 16:41:49 +0100 Subject: [PATCH] enable dnf module for 4.3+ --- manifests/repo.pp | 13 +++++++++++++ spec/classes/repo_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/manifests/repo.pp b/manifests/repo.pp index f83c6928..2baa3c85 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -22,4 +22,17 @@ enabled => true, } -> anchor { 'katello::repo': } # lint:ignore:anchor_resource + + Anchor <| title == 'foreman::repo' |> -> Yumrepo['katello'] + + if $facts['os']['release']['major'] != '7' and ($repo_version == 'nightly' or versioncmp($repo_version, '4.3') >= 0) { + package { 'katello-dnf-module': + ensure => $dist, + name => 'katello', + enable_only => true, + provider => 'dnfmodule', + require => Yumrepo['katello'], + before => Anchor['katello::repo'], + } + } } diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index dd0f76c4..30867dd0 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -17,6 +17,8 @@ end context 'with manage_repo => true' do + let(:facts) { { os: { release: { major: '8' } } } } + let :params do { 'repo_version' => '3.14', @@ -35,4 +37,26 @@ .with_enabled(true) end end + context 'with manage_repo => true on EL8 with modular metadata' do + let(:facts) { { os: { release: { major: '8' } } } } + + let :params do + { + 'repo_version' => 'nightly', + 'gpgcheck' => false, + } + end + + it do + is_expected.to contain_yumrepo('katello') + .with_descr('katello nightly') + .with_baseurl("https://yum.theforeman.org/katello/nightly/katello/el8/\$basearch/") + .with_gpgcheck(false) + .with_enabled(true) + + is_expected.to contain_package('katello-dnf-module') + .with_ensure('el8') + .with_provider('dnfmodule') + end + end end