[RedHat] Set up yum repositories from repo file
This patch allows operators to use .repo file directly to configure
yum repogitories on RHEL/CentOS node, so that they can use the .repo
file provided in RDO repository directly.
This is useful especially in RDO CentOS8, because now it provides
seprated repogitory namespaces for modules.
Depends-on: https://review.opendev.org/#/c/742146/
Change-Id: I53c30652df0168f941bec10d0f462e44512ce39a
(cherry picked from commit cc751868cf)
This commit is contained in:
@@ -31,6 +31,10 @@
|
||||
# create_resource. See examples folder for some useful examples.
|
||||
# Defaults to {}
|
||||
#
|
||||
# [*repo_source_hash*]
|
||||
# (optional) A hash of repo files
|
||||
# Defaults to {}
|
||||
#
|
||||
# [*repo_defaults*]
|
||||
# (optional) The defaults for the yumrepo resources that will be
|
||||
# created using create_resource.
|
||||
@@ -71,6 +75,7 @@ class openstack_extras::repo::redhat::redhat(
|
||||
$manage_virt = true,
|
||||
$manage_epel = false,
|
||||
$repo_hash = {},
|
||||
$repo_source_hash = {},
|
||||
$repo_defaults = {},
|
||||
$gpgkey_hash = {},
|
||||
$gpgkey_defaults = {},
|
||||
@@ -84,6 +89,7 @@ class openstack_extras::repo::redhat::redhat(
|
||||
validate_legacy(Boolean, 'validate_bool', $manage_rdo)
|
||||
validate_legacy(Boolean, 'validate_bool', $manage_epel)
|
||||
validate_legacy(Hash, 'validate_hash', $repo_hash)
|
||||
validate_legacy(Hash, 'validate_hash', $repo_source_hash)
|
||||
validate_legacy(Hash, 'validate_hash', $repo_defaults)
|
||||
validate_legacy(Hash, 'validate_hash', $gpgkey_hash)
|
||||
validate_legacy(Hash, 'validate_hash', $gpgkey_defaults)
|
||||
@@ -168,6 +174,13 @@ class openstack_extras::repo::redhat::redhat(
|
||||
create_resources('yumrepo', $repo_hash, $_repo_defaults)
|
||||
create_resources('file', $gpgkey_hash, $_gpgkey_defaults)
|
||||
|
||||
$repo_source_hash.each | $filename, $url | {
|
||||
file { $filename:
|
||||
path => "/etc/yum.repos.d/${filename}",
|
||||
source => $url,
|
||||
}
|
||||
}
|
||||
|
||||
if ((versioncmp($::puppetversion, '3.5') > 0) and $purge_unmanaged) {
|
||||
resources { 'yumrepo': purge => true }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``repo::redhat::redhat::repo_source_hash`` parameter has been
|
||||
added, so that repo file can be passed directly to configure yum
|
||||
repogitories on CentOS or RHEL nodes.
|
||||
@@ -252,6 +252,26 @@ describe 'openstack_extras::repo::redhat::redhat' do
|
||||
|
||||
it { should_not contain_exec('installing_yum-plugin-priorities') }
|
||||
end
|
||||
|
||||
context 'with repo_source_hash' do
|
||||
let :params do
|
||||
default_params.merge!({
|
||||
:repo_source_hash => {
|
||||
'delorean.repo' => 'https://trunk.rdoproject.org/centos8-master/puppet-passed-ci/delorean.repo',
|
||||
'delorean-deps.repo' => 'https://trunk.rdoproject.org/centos8-master/delorean-deps.repo'}})
|
||||
end
|
||||
|
||||
it {
|
||||
should contain_file('delorean.repo').with(
|
||||
:path => '/etc/yum.repos.d/delorean.repo',
|
||||
:source => 'https://trunk.rdoproject.org/centos8-master/puppet-passed-ci/delorean.repo'
|
||||
)
|
||||
should contain_file('delorean-deps.repo').with(
|
||||
:path => '/etc/yum.repos.d/delorean-deps.repo',
|
||||
:source => 'https://trunk.rdoproject.org/centos8-master/delorean-deps.repo'
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
||||
Reference in New Issue
Block a user