Browse Source

[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
changes/67/741867/7
Takashi Kajinami 1 year ago
parent
commit
cc751868cf
  1. 13
      manifests/repo/redhat/redhat.pp
  2. 6
      releasenotes/notes/repo-redhat-repofile-bfafdae3f8b158b2.yaml
  3. 20
      spec/classes/openstack_extras_repo_redhat_redhat_spec.rb

13
manifests/repo/redhat/redhat.pp

@ -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 }
}

6
releasenotes/notes/repo-redhat-repofile-bfafdae3f8b158b2.yaml

@ -0,0 +1,6 @@
---
features:
- |
The new ``manifests::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.

20
spec/classes/openstack_extras_repo_redhat_redhat_spec.rb

@ -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({

Loading…
Cancel
Save