Skip to content

Commit

Permalink
Support setting the priority of the Yum repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
nbarrientos committed May 10, 2021
1 parent 0520a49 commit 5933da0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions manifests/repos/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Boolean $gpgcheck,
Stdlib::HTTPUrl $baseurl,
Optional[String] $keypath = undef,
Variant[Integer[0, 99], Enum['absent']] $priority = 'absent',
) {
$_keypath = pick($keypath, "${baseurl}/releases/${repo}/RPM-GPG-KEY-foreman")
$gpgcheck_enabled_default = $gpgcheck ? {
Expand All @@ -22,25 +23,29 @@
gpgcheck => $gpgcheck_enabled,
gpgkey => $_keypath,
enabled => '1',
priority => $priority,
}
yumrepo { "${name}-source":
descr => "Foreman ${repo} - source",
baseurl => "${baseurl}/releases/${repo}/${yumcode}/source",
gpgcheck => $gpgcheck_enabled,
gpgkey => $_keypath,
enabled => '0',
priority => $priority,
}
yumrepo { "${name}-plugins":
descr => "Foreman plugins ${repo}",
baseurl => "${baseurl}/plugins/${repo}/${yumcode}/\$basearch",
gpgcheck => '0',
enabled => '1',
priority => $priority,
}
yumrepo { "${name}-plugins-source":
descr => "Foreman plugins ${repo} - source",
baseurl => "${baseurl}/plugins/${repo}/${yumcode}/source",
gpgcheck => '0',
enabled => '0',
priority => $priority,
}
# Foreman 2.0 dropped the separate rails repository
yumrepo { "${name}-rails":
Expand Down
33 changes: 33 additions & 0 deletions spec/defines/foreman_repos_yum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@
.with_gpgcheck('0')
.with_gpgkey('http://example.org/releases/nightly/RPM-GPG-KEY-foreman')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-source')
.with_descr('Foreman nightly - source')
.with_baseurl('http://example.org/releases/nightly/el7/source')
.with_gpgcheck('0')
.with_gpgkey('http://example.org/releases/nightly/RPM-GPG-KEY-foreman')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-plugins')
.with_descr('Foreman plugins nightly')
.with_baseurl('http://example.org/plugins/nightly/el7/$basearch')
.with_gpgcheck('0')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-plugins-source')
.with_descr('Foreman plugins nightly - source')
.with_baseurl('http://example.org/plugins/nightly/el7/source')
.with_gpgcheck('0')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-rails').with_ensure('absent')
end
Expand All @@ -57,6 +61,23 @@
end
end
end

context 'priority => 10' do
let(:params) { super().merge(priority: 10) }
it 'should contain repo, plugins and source with correct priority' do
should contain_yumrepo('foreman')
.with_priority(10)

should contain_yumrepo('foreman-source')
.with_priority(10)

should contain_yumrepo('foreman-plugins')
.with_priority(10)

should contain_yumrepo('foreman-plugins-source')
.with_priority(10)
end
end
end

context 'gpgcheck => false' do
Expand All @@ -69,25 +90,29 @@
.with_gpgcheck('0')
.with_gpgkey('https://yum.theforeman.org/releases/nightly/RPM-GPG-KEY-foreman')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-source')
.with_descr('Foreman nightly - source')
.with_baseurl('https://yum.theforeman.org/releases/nightly/el7/source')
.with_gpgcheck('0')
.with_gpgkey('https://yum.theforeman.org/releases/nightly/RPM-GPG-KEY-foreman')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-plugins')
.with_descr('Foreman plugins nightly')
.with_baseurl('https://yum.theforeman.org/plugins/nightly/el7/$basearch')
.with_gpgcheck('0')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-plugins-source')
.with_descr('Foreman plugins nightly - source')
.with_baseurl('https://yum.theforeman.org/plugins/nightly/el7/source')
.with_gpgcheck('0')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-rails').with_ensure('absent')
end
Expand All @@ -107,25 +132,29 @@
.with_gpgcheck('1')
.with_gpgkey('https://yum.theforeman.org/releases/1.19/RPM-GPG-KEY-foreman')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-source')
.with_descr('Foreman 1.19 - source')
.with_baseurl('https://yum.theforeman.org/releases/1.19/el7/source')
.with_gpgcheck('1')
.with_gpgkey('https://yum.theforeman.org/releases/1.19/RPM-GPG-KEY-foreman')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-plugins')
.with_descr('Foreman plugins 1.19')
.with_baseurl('https://yum.theforeman.org/plugins/1.19/el7/$basearch')
.with_gpgcheck('0')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-plugins-source')
.with_descr('Foreman plugins 1.19 - source')
.with_baseurl('https://yum.theforeman.org/plugins/1.19/el7/source')
.with_gpgcheck('0')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-rails').with_ensure('absent')
end
Expand All @@ -141,25 +170,29 @@
.with_gpgcheck('0')
.with_gpgkey('https://yum.theforeman.org/releases/1.19/RPM-GPG-KEY-foreman')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-source')
.with_descr('Foreman 1.19 - source')
.with_baseurl('https://yum.theforeman.org/releases/1.19/el7/source')
.with_gpgcheck('0')
.with_gpgkey('https://yum.theforeman.org/releases/1.19/RPM-GPG-KEY-foreman')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-plugins')
.with_descr('Foreman plugins 1.19')
.with_baseurl('https://yum.theforeman.org/plugins/1.19/el7/$basearch')
.with_gpgcheck('0')
.with_enabled('1')
.with_priority('absent')

should contain_yumrepo('foreman-plugins-source')
.with_descr('Foreman plugins 1.19 - source')
.with_baseurl('https://yum.theforeman.org/plugins/1.19/el7/source')
.with_gpgcheck('0')
.with_enabled('0')
.with_priority('absent')

should contain_yumrepo('foreman-rails').with_ensure('absent')
end
Expand Down

0 comments on commit 5933da0

Please sign in to comment.