Merge "Cleanup RedHat repo"

This commit is contained in:
Zuul 2021-05-02 13:04:05 +00:00 committed by Gerrit Code Review
commit 8882469677
4 changed files with 384 additions and 350 deletions

View File

@ -1,36 +1,23 @@
# == Class: openstack_extras::repo::redhat::params
#
# This repo sets defaults for use with the redhat
# osfamily repo classes.
# OS family repo classes.
#
class openstack_extras::repo::redhat::params
{
$release = 'victoria'
class openstack_extras::repo::redhat::params {
$release = 'victoria'
$repo_defaults = { 'enabled' => '1',
'gpgcheck' => '1',
'notify' => 'Exec[yum_refresh]',
'mirrorlist' => 'absent',
'require' => 'Anchor[openstack_extras_redhat]',
}
$repo_defaults = {
'enabled' => '1',
'gpgcheck' => '1',
'mirrorlist' => 'absent',
'notify' => 'Exec[yum_refresh]',
'require' => 'Anchor[openstack_extras_redhat]',
}
$gpgkey_defaults = { 'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'before' => 'Anchor[openstack_extras_redhat]',
}
case $::operatingsystem {
'centos', 'redhat', 'scientific', 'slc': {
$dist_full = 'epel-'
$dist_short = 'el'
}
'fedora': {
$dist_full = 'fedora-'
$dist_short = 'f'
}
default: {
warning('Unrecognised operatingsystem')
}
$gpgkey_defaults = {
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'before' => 'Anchor[openstack_extras_redhat]',
}
}

View File

@ -1,89 +1,89 @@
# == Class: openstack_extras::repo::redhat::redhat
#
# This repo sets up yum repos for use with the redhat
# osfamily and redhat operatingsystem.
# This class sets up repositories for use with the supported
# operating systems in the RedHat OS family.
#
# === Parameters:
#
# [*release*]
# (optional) The openstack release to use if managing rdo
# Defaults to $::openstack_extras::repo::redhat::params::release
# (Optional) The OpenStack release to use.
# Defaults to $openstack_extras::repo::redhat::params::release
#
# [*manage_rdo*]
# (optional) Whether to create a predefined yumrepo resource
# for the RDO OpenStack repository provided by RedHat
# (Optional) Whether to create a yumrepo resource for the
# RDO OpenStack repository.
# Defaults to true
#
# [*manage_virt*]
# (optional) Whether to create a predefined yumrepo resource
# for the RDO CentOS QEMU EV epository provided by RedHat.
# This repository has been required starting from Newton.
# (Optional) Whether to create a yumrepo resource for the
# Advanced Virtualization repository.
# Defaults to true
#
# [*manage_epel*]
# (optional) Whether to create a predefined yumrepo resource
# for the EPEL repository provided by RedHat
# Note: EPEL is not required when deploying OpenStack with RDO.
# (Optional) Whether to create a predefined yumrepo resource for
# the EPEL repository. Note EPEL is not required for deploying
# OpenStack with RDO.
# Defaults to false
#
# [*repo_hash*]
# (optional) A hash of yumrepo resources that will be passed to
# (Optional) A hash of yumrepo resources that will be passed to
# create_resource. See examples folder for some useful examples.
# Defaults to {}
#
# [*repo_source_hash*]
# (optional) A hash of repo files
# (Optional) A hash of repo files.
# Defaults to {}
#
# [*repo_replace*]
# (optional) Replace repo files when their contents are changed
# (Optional) Replace repo files when their contents are changed.
# Defaults to true
#
# [*repo_defaults*]
# (optional) The defaults for the yumrepo resources that will be
# (Optional) The defaults for the yumrepo resources that will be
# created using create_resource.
# Defaults to $::openstack_extras::repo::redhat::params::repo_defaults
# Defaults to $openstack_extras::repo::redhat::params::repo_defaults
#
# [*gpgkey_hash*]
# (optional) A hash of file resources that will be passed to
# create_resource. See examples folder for some useful examples.
# (Optional) A hash of file resources that will be passed to
# create_resources. See examples folder for some useful examples.
# Defaults to {}
#
# [*gpgkey_defaults*]
# (optional) The default resource attributes to
# create gpgkeys with.
# Defaults to $::openstack_extras::repo::redhat::params::gpgkey_defaults
# (Optional) The default resource attributes to create gpgkeys with.
# Defaults to $openstack_extras::repo::redhat::params::gpgkey_defaults
#
# [*purge_unmanaged*]
# (optional) Purge the yum.repos.d directory of
# all repositories not managed by Puppet
# (Optional) Purge the yum.repos.d directory of all repositories
# not managed by Puppet.
# Defaults to false
#
# [*package_require*]
# (optional) Set all packages to require all
# yumrepos be set.
# (Optional) Set all packages to require all yumrepos be set.
# Defaults to false
#
# [*manage_priorities*]
# (optional) Whether to install yum-plugin-priorities package so
# 'priority' value in yumrepo will be effective.
# Defaults to true
#
# [*centos_mirror_url*]
# (optional) URL of CentOS mirror.
# (Optional) URL of CentOS mirror.
# Defaults to 'http://mirror.centos.org'
#
# [*update_packages*]
# (optional) Whether to update all packages after yum repositories are
# (Optional) Whether to update all packages after yum repositories are
# configured.
# Defaults to false
#
# [*stream*]
# (optional) Is this CentOS Stream and we should adjust mirrors thereafter.
# (Optional) Is this CentOS Stream and should we adjust mirrors.
# Defaults to true
#
class openstack_extras::repo::redhat::redhat(
$release = $::openstack_extras::repo::redhat::params::release,
# DEPRECATED PARAMS
# =================
#
# [*manage_priorities*]
# (Optional) Whether to install yum-plugin-priorities package so
# 'priority' value in yumrepo will be effective.
# Defaults to undef
#
class openstack_extras::repo::redhat::redhat (
$release = $openstack_extras::repo::redhat::params::release,
$manage_rdo = true,
$manage_virt = true,
$manage_epel = false,
@ -95,10 +95,11 @@ class openstack_extras::repo::redhat::redhat(
$gpgkey_defaults = {},
$purge_unmanaged = false,
$package_require = false,
$manage_priorities = true,
$centos_mirror_url = 'http://mirror.centos.org',
$update_packages = false,
$stream = true,
# DEPRECATED PARAMS
$manage_priorities = undef,
) inherits openstack_extras::repo::redhat::params {
validate_legacy(String, 'validate_string', $release)
@ -111,14 +112,18 @@ class openstack_extras::repo::redhat::redhat(
validate_legacy(Hash, 'validate_hash', $gpgkey_defaults)
validate_legacy(Boolean, 'validate_bool', $purge_unmanaged)
validate_legacy(Boolean, 'validate_bool', $package_require)
validate_yum_hash($repo_hash)
$_repo_defaults = merge($::openstack_extras::repo::redhat::params::repo_defaults, $repo_defaults)
$_gpgkey_defaults = merge($::openstack_extras::repo::redhat::params::gpgkey_defaults, $gpgkey_defaults)
if $manage_priorities != undef {
warning('openstack_extras::repo::redhat::redhat::manage_priorities parameter is deprecated and will be removed')
}
$_repo_defaults = merge($openstack_extras::repo::redhat::params::repo_defaults, $repo_defaults)
$_gpgkey_defaults = merge($openstack_extras::repo::redhat::params::gpgkey_defaults, $gpgkey_defaults)
$os_major = $::os['release']['major']
$centos_major = $stream ? {
true => "${os_major}-stream",
default => $os_major
true => "${facts['os']['release']['major']}-stream",
default => $facts['os']['release']['major']
}
anchor { 'openstack_extras_redhat': }
@ -134,7 +139,8 @@ class openstack_extras::repo::redhat::redhat(
}
}
$rdokey_hash = { '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud' => {
$rdokey_hash = {
'/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud' => {
'source' => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud'
}
}
@ -143,27 +149,23 @@ class openstack_extras::repo::redhat::redhat(
create_resources('yumrepo', $rdo_hash, $_repo_defaults)
}
if $manage_virt and ($::operatingsystem != 'Fedora') {
if Integer.new($os_major) >= 8 {
if $stream {
$virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/advancedvirt-common/"
} else {
$virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/advanced-virtualization/"
}
if $manage_virt and ($facts['os']['name'] != 'Fedora') {
if $stream {
$virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/advancedvirt-common/"
} else {
$virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/kvm-common/"
$virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/advanced-virtualization/"
}
$virt_hash = {
'rdo-qemu-ev' => {
'baseurl' => $virt_baseurl,
'descr' => "RDO CentOS-${$centos_major} - QEMU EV",
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
'baseurl' => $virt_baseurl,
'descr' => "RDO CentOS-${$centos_major} - QEMU EV",
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
}
}
$virtkey_hash = { '/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization' => {
$virtkey_hash = {
'/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization' => {
'source' => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Virtualization'
}
}
@ -172,80 +174,60 @@ class openstack_extras::repo::redhat::redhat(
create_resources('yumrepo', $virt_hash, $_repo_defaults)
}
if $manage_epel {
if ($::osfamily == 'RedHat' and
$::operatingsystem != 'Fedora')
{
$epel_hash = { 'epel' => {
'metalink' => "https://mirrors.fedoraproject.org/metalink?repo=epel-${::operatingsystemmajrelease}&arch=\$basearch",
'descr' => "Extra Packages for Enterprise Linux ${::operatingsystemmajrelease} - \$basearch",
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}",
'failovermethod' => 'priority'
}
if ($manage_epel and $facts['os']['name'] != 'Fedora') {
$epel_hash = {
'epel' => {
'metalink' => "https://mirrors.fedoraproject.org/metalink?repo=epel-${facts['os']['release']['major']}&arch=\$basearch",
'descr' => "Extra Packages for Enterprise Linux ${facts['os']['release']['major']} - \$basearch",
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${facts['os']['release']['major']}",
'failovermethod' => 'priority'
}
$epelkey_hash = { "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}" => {
'source' => "puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}"
}
}
create_resources('file', $epelkey_hash, $_gpgkey_defaults)
create_resources('yumrepo', $epel_hash, $_repo_defaults)
}
$epelkey_hash = {
"/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${facts['os']['release']['major']}" => {
'source' => "puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-${facts['os']['release']['major']}"
}
}
create_resources('file', $epelkey_hash, $_gpgkey_defaults)
create_resources('yumrepo', $epel_hash, $_repo_defaults)
}
validate_yum_hash($repo_hash)
create_resources('yumrepo', $repo_hash, $_repo_defaults)
create_resources('file', $gpgkey_hash, $_gpgkey_defaults)
$repo_source_hash.each | $filename, $url | {
$repo_source_hash.each |$filename, $url| {
file { $filename:
path => "/etc/yum.repos.d/${filename}",
source => $url,
notify => Exec['yum_refresh'],
replace => $repo_replace,
notify => Exec['yum_refresh'],
}
}
if ((versioncmp($::puppetversion, '3.5') > 0) and $purge_unmanaged) {
resources { 'yumrepo': purge => true }
}
if $manage_priorities and ($::operatingsystem != 'Fedora') {
if Integer.new($os_major) < 8 {
# yum-plugin-priorities is unavailable since RHEL/CentOS8
exec { 'installing_yum-plugin-priorities':
command => '/usr/bin/yum install -y yum-plugin-priorities',
logoutput => 'on_failure',
tries => 3,
try_sleep => 1,
unless => '/usr/bin/rpm -qa | /usr/bin/grep -q yum-plugin-priorities',
}
Exec['installing_yum-plugin-priorities'] -> Yumrepo<||>
if $purge_unmanaged {
resources { 'yumrepo':
purge => true
}
}
if $package_require {
Yumrepo<||> -> Package<||>
}
if ($::operatingsystem == 'Fedora') or (Integer.new($os_major) >= 8) {
$yum_command = 'dnf'
} else {
$yum_command = 'yum'
Yumrepo<||> -> Package<||>
}
exec { 'yum_refresh':
command => "/usr/bin/${yum_command} clean all",
command => '/usr/bin/dnf clean all',
refreshonly => true,
}
if $update_packages {
exec { 'yum_update':
command => "/usr/bin/${yum_command} update -y",
command => '/usr/bin/dnf update -y',
refreshonly => true,
timeout => 600,
}
Exec['yum_refresh'] ~> Exec['yum_update'] -> Package <||>
}
else {

View File

@ -0,0 +1,5 @@
---
deprecations:
- |
The manage_priorities parameter in openstack_extras::repo::redhat::redhat
is deprecated, has no effect and will be removed in a future release.

View File

@ -2,79 +2,26 @@ require 'spec_helper'
describe 'openstack_extras::repo::redhat::redhat' do
shared_examples 'openstack_extras::repo::redhat::redhat' do
let :class_params do
{
:manage_rdo => true,
:manage_epel => true,
:repo_hash => {},
:gpgkey_hash => {},
:purge_unmanaged => false,
:package_require => false
}
end
let :paramclass_defaults do
{
:release => 'victoria',
:repo_defaults => { 'enabled' => '1',
'gpgcheck' => '1',
'notify' => 'Exec[yum_refresh]',
'mirrorlist' => 'absent',
'require' => 'Anchor[openstack_extras_redhat]'
},
:gpgkey_defaults => { 'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'before' => 'Anchor[openstack_extras_redhat]'
}
}
end
let :default_params do
class_params.merge!(paramclass_defaults)
end
context 'with default parameters' do
let :params do
{}
end
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://mirror.centos.org/centos/7-stream/cloud/$basearch/openstack-victoria/",
:descr => 'OpenStack Victoria Repository',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
it { should contain_yumrepo('rdo-qemu-ev').with(
:baseurl => "http://mirror.centos.org/centos/7-stream/virt/$basearch/kvm-common/",
:descr => 'RDO CentOS-7-stream - QEMU EV',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
it { should contain_exec('installing_yum-plugin-priorities').with(
:command => '/usr/bin/yum install -y yum-plugin-priorities',
:logoutput => 'on_failure',
:tries => 3,
:try_sleep => 1,
:unless => '/usr/bin/rpm -qa | /usr/bin/grep -q yum-plugin-priorities',
) }
it { should contain_anchor('openstack_extras_redhat') }
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud',
:owner => 'root',
:group => 'root',
:mode => '0644',
:before => 'Anchor[openstack_extras_redhat]'
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/cloud/$basearch/openstack-victoria/",
:descr => "OpenStack Victoria Repository",
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization').with(
@ -82,101 +29,152 @@ describe 'openstack_extras::repo::redhat::redhat' do
:owner => 'root',
:group => 'root',
:mode => '0644',
:before => 'Anchor[openstack_extras_redhat]'
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should_not contain_yumrepo('epel') }
end
context 'with major release 8 or later and virt repo enabled' do
let :params do
default_params.merge!( :manage_virt => true )
end
before do
facts.merge!( :os => {'release' => {'major' => 8}} )
end
it { should contain_yumrepo('rdo-qemu-ev').with(
:baseurl => "http://mirror.centos.org/centos/8-stream/virt/$basearch/advancedvirt-common/",
:descr => 'RDO CentOS-8-stream - QEMU EV',
:baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/virt/$basearch/advancedvirt-common/",
:descr => "RDO CentOS-#{facts[:operatingsystemmajrelease]}-stream - QEMU EV",
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
it { should_not contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}") }
it { should_not contain_yumrepo('epel') }
it { should_not contain_resources('yumrepo').with_purge(true) }
it { should contain_exec('yum_refresh').with(
:command => '/usr/bin/dnf clean all',
:refreshonly => true,
)}
it { should_not contain_exec('yum_update') }
end
context 'with parameters' do
let :params do
{
:manage_rdo => false,
:manage_virt => false,
:manage_epel => true,
:purge_unmanaged => true,
:package_require => true,
:update_packages => true,
}
end
it { should contain_anchor('openstack_extras_redhat') }
it { should_not contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud') }
it { should_not contain_yumrepo('rdo-release') }
it { should_not contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization') }
it { should_not contain_yumrepo('rdo-qemu-ev') }
it { should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}").with(
:source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}",
:owner => 'root',
:group => 'root',
:mode => '0644',
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('epel').with(
:metalink => "https://mirrors.fedoraproject.org/metalink?repo=epel-#{facts[:operatingsystemmajrelease]}&arch=\$basearch",
:descr => "Extra Packages for Enterprise Linux #{facts[:operatingsystemmajrelease]} - \$basearch",
:gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}",
:failovermethod => 'priority',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_resources('yumrepo').with_purge(true) }
it { should contain_exec('yum_refresh').with(
:command => '/usr/bin/dnf clean all',
:refreshonly => true,
)}
it { should contain_exec('yum_update').with(
:command => '/usr/bin/dnf update -y',
:refreshonly => true,
:timeout => 600,
)}
end
context 'with major release 8' do
before do
facts.merge!( :os => {'release' => {'major' => 8}} )
end
it { should_not contain_exec('installing_yum-plugin-priorities') }
end
context 'with major release 8 and stream is false' do
context 'with stream is false' do
let :params do
default_params.merge!( :stream => false )
end
before do
facts.merge!( :os => {'release' => {'major' => 8}} )
{
:manage_rdo => true,
:manage_virt => true,
:stream => false,
}
end
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://mirror.centos.org/centos/8/cloud/$basearch/openstack-victoria/",
:baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}/cloud/\$basearch/openstack-victoria/",
)}
it { should contain_yumrepo('rdo-qemu-ev').with(
:baseurl => "http://mirror.centos.org/centos/8/virt/$basearch/advanced-virtualization/",
:baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}/virt/\$basearch/advanced-virtualization/",
:descr => "RDO CentOS-#{facts[:operatingsystemmajrelease]} - QEMU EV",
)}
end
context 'with overridden release' do
let :params do
default_params.merge!({ :release => 'juno' })
{
:release => 'juno',
:manage_rdo => true,
}
end
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://mirror.centos.org/centos/7-stream/cloud/\$basearch/openstack-juno/",
:baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/cloud/\$basearch/openstack-juno/",
:descr => 'OpenStack Juno Repository',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud'
)}
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud'
)}
end
context 'with overridden repo hash' do
context 'with overridden repo_hash and gpgkey_hash' do
let :params do
default_params.merge!({ :repo_hash => {
'CentOS-Base' => {
'baseurl' => 'http://mymirror/$releasever/os/$basearch/',
'descr' => 'CentOS-$releasever - Base',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6'
},
'CentOS-Updates' => {
'baseurl' => 'http://mymirror/$releasever/updates/$basearch/',
'descr' => 'CentOS-$releasever - Updates',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6',
}
}
})
{
:repo_hash => {
'CentOS-Base' => {
'baseurl' => 'http://mymirror/$releasever/os/$basearch/',
'descr' => 'CentOS-$releasever - Base',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS',
},
'CentOS-Updates' => {
'baseurl' => 'http://mymirror/$releasever/updates/$basearch/',
'descr' => 'CentOS-$releasever - Updates',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS',
}
},
:gpgkey_hash => {
'/etc/pki/rpm-gpg/RPM-GPG-KEY-Something' => {
'source' => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-Something',
}
},
}
end
it { should contain_yumrepo('CentOS-Base').with(
:baseurl => "http://mymirror/$releasever/os/$basearch/",
:descr => "CentOS-$releasever - Base",
:baseurl => 'http://mymirror/$releasever/os/$basearch/',
:descr => 'CentOS-$releasever - Base',
:enabled => '1',
:gpgcheck => '1',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS',
:mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
it { should contain_yumrepo('CentOS-Updates').with(
@ -184,111 +182,177 @@ describe 'openstack_extras::repo::redhat::redhat' do
:descr => "CentOS-$releasever - Updates",
:enabled => '1',
:gpgcheck => '1',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS',
:mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
end
context 'with overridden repo default' do
let :params do
default_params.merge!({ :repo_defaults => {
'proxy' => 'http://my.proxy.com:8000'
},
:centos_mirror_url => 'http://mirror.dfw.rax.openstack.org',
})
end
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://mirror.dfw.rax.openstack.org/centos/7-stream/cloud/\$basearch/openstack-victoria/",
:descr => 'OpenStack Victoria Repository',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud',
:proxy => 'http://my.proxy.com:8000'
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-Something').with(
:source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-Something',
:owner => 'root',
:group => 'root',
:mode => '0644',
:before => 'Anchor[openstack_extras_redhat]',
)}
end
context 'with overridden gpgkey default' do
let :params do
default_params.merge!({ :gpgkey_defaults => {
'owner' => 'steve'
}
})
end
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
:owner => 'steve'
)}
end
context 'with epel management enabled' do
let :params do
default_params.merge!({ :manage_epel => true })
end
it { should contain_yumrepo('epel').with(
:metalink => "https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch",
:descr => 'Extra Packages for Enterprise Linux 7 - $basearch',
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7',
:failovermethod => 'priority',
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)}
end
context 'with epel management disabled' do
let :params do
default_params.merge!({ :manage_epel => false })
end
it { should_not contain_yumrepo('epel') }
end
context 'with rdo management disabled' do
let :params do
default_params.merge!({ :manage_rdo => false })
end
it { should_not contain_yumrepo('rdo-release') }
end
context 'with rdo-virt management disabled' do
let :params do
default_params.merge!({ :manage_virt => false })
end
it { should_not contain_yumrepo('rdo-qemu-ev') }
end
context 'with manage_priorities disabled' do
let :params do
default_params.merge!({ :manage_priorities => false })
end
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'}})
'delorean.repo' => 'https://trunk.rdoproject.org/centos/puppet-passed-ci/delorean.repo',
'delorean-deps.repo' => 'https://trunk.rdoproject.org/centos/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'
)
}
it { should contain_file('delorean.repo').with(
:path => '/etc/yum.repos.d/delorean.repo',
:source => 'https://trunk.rdoproject.org/centos/puppet-passed-ci/delorean.repo',
:replace => true,
:notify => 'Exec[yum_refresh]',
)}
it { should contain_file('delorean-deps.repo').with(
:path => '/etc/yum.repos.d/delorean-deps.repo',
:source => 'https://trunk.rdoproject.org/centos/delorean-deps.repo',
:replace => true,
:notify => 'Exec[yum_refresh]',
)}
end
context 'with repo_source_hash and repo_replace is false' do
let :params do
{
:repo_source_hash => {
'thing.repo' => 'https://trunk.rdoproject.org/some/thing.repo',
},
:repo_replace => false,
}
end
it { should contain_file('thing.repo').with(
:path => '/etc/yum.repos.d/thing.repo',
:source => 'https://trunk.rdoproject.org/some/thing.repo',
:replace => false,
:notify => 'Exec[yum_refresh]',
)}
end
context 'with centos_mirror_url' do
let :params do
{
:manage_rdo => true,
:manage_virt => true,
:centos_mirror_url => 'http://foo.bar',
}
end
it { should contain_yumrepo('rdo-release').with(
:baseurl => "http://foo.bar/centos/#{facts[:operatingsystemmajrelease]}-stream/cloud/\$basearch/openstack-victoria/",
)}
it { should contain_yumrepo('rdo-qemu-ev').with(
:baseurl => "http://foo.bar/centos/#{facts[:operatingsystemmajrelease]}-stream/virt/\$basearch/advancedvirt-common/",
)}
end
context 'with repo_defaults and gpgkey_defaults' do
let :params do
{
:manage_rdo => true,
:manage_virt => true,
:manage_epel => true,
:repo_hash => {
'CentOS-Example' => {
'baseurl' => 'http://example.com/$releasever/os/$basearch/',
'descr' => 'CentOS-$releasever - Example',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Example',
},
},
:gpgkey_hash => {
'/etc/pki/rpm-gpg/RPM-GPG-KEY-Example' => {
'source' => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-Example',
}
},
:repo_defaults => {
'proxy' => 'http://example.com:8000',
},
:gpgkey_defaults => {
'owner' => 'steve',
'force' => true,
},
}
end
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with(
:owner => 'steve',
:group => 'root',
:mode => '0644',
:force => true,
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('rdo-release').with(
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:proxy => 'http://example.com:8000',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization').with(
:owner => 'steve',
:group => 'root',
:mode => '0644',
:force => true,
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('rdo-qemu-ev').with(
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:proxy => 'http://example.com:8000',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}").with(
:owner => 'steve',
:group => 'root',
:mode => '0644',
:force => true,
:before => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('epel').with(
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:proxy => 'http://example.com:8000',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_yumrepo('CentOS-Example').with(
:enabled => '1',
:gpgcheck => '1',
:mirrorlist => 'absent',
:proxy => 'http://example.com:8000',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-Example').with(
:owner => 'steve',
:group => 'root',
:mode => '0644',
:force => true,
:before => 'Anchor[openstack_extras_redhat]',
)}
end
end
@ -297,11 +361,7 @@ describe 'openstack_extras::repo::redhat::redhat' do
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :operatingsystem => 'RedHat',
:operatingsystemrelease => '7.1',
:operatingsystemmajrelease => '7',
:os => {'release' => {'major' => '7'}},
:puppetversion => Puppet.version }))
facts.merge!(OSDefaults.get_facts())
end
if facts[:osfamily] == 'RedHat'