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 # == Class: openstack_extras::repo::redhat::params
# #
# This repo sets defaults for use with the redhat # This repo sets defaults for use with the redhat
# osfamily repo classes. # OS family repo classes.
# #
class openstack_extras::repo::redhat::params class openstack_extras::repo::redhat::params {
{ $release = 'victoria'
$release = 'victoria'
$repo_defaults = { 'enabled' => '1', $repo_defaults = {
'gpgcheck' => '1', 'enabled' => '1',
'notify' => 'Exec[yum_refresh]', 'gpgcheck' => '1',
'mirrorlist' => 'absent', 'mirrorlist' => 'absent',
'require' => 'Anchor[openstack_extras_redhat]', 'notify' => 'Exec[yum_refresh]',
} 'require' => 'Anchor[openstack_extras_redhat]',
}
$gpgkey_defaults = { 'owner' => 'root', $gpgkey_defaults = {
'group' => 'root', 'owner' => 'root',
'mode' => '0644', 'group' => 'root',
'before' => 'Anchor[openstack_extras_redhat]', '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')
}
} }
} }

View File

@ -1,89 +1,89 @@
# == Class: openstack_extras::repo::redhat::redhat # == Class: openstack_extras::repo::redhat::redhat
# #
# This repo sets up yum repos for use with the redhat # This class sets up repositories for use with the supported
# osfamily and redhat operatingsystem. # operating systems in the RedHat OS family.
# #
# === Parameters: # === Parameters:
# #
# [*release*] # [*release*]
# (optional) The openstack release to use if managing rdo # (Optional) The OpenStack release to use.
# Defaults to $::openstack_extras::repo::redhat::params::release # Defaults to $openstack_extras::repo::redhat::params::release
# #
# [*manage_rdo*] # [*manage_rdo*]
# (optional) Whether to create a predefined yumrepo resource # (Optional) Whether to create a yumrepo resource for the
# for the RDO OpenStack repository provided by RedHat # RDO OpenStack repository.
# Defaults to true # Defaults to true
# #
# [*manage_virt*] # [*manage_virt*]
# (optional) Whether to create a predefined yumrepo resource # (Optional) Whether to create a yumrepo resource for the
# for the RDO CentOS QEMU EV epository provided by RedHat. # Advanced Virtualization repository.
# This repository has been required starting from Newton.
# Defaults to true # Defaults to true
# #
# [*manage_epel*] # [*manage_epel*]
# (optional) Whether to create a predefined yumrepo resource # (Optional) Whether to create a predefined yumrepo resource for
# for the EPEL repository provided by RedHat # the EPEL repository. Note EPEL is not required for deploying
# Note: EPEL is not required when deploying OpenStack with RDO. # OpenStack with RDO.
# Defaults to false # Defaults to false
# #
# [*repo_hash*] # [*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. # create_resource. See examples folder for some useful examples.
# Defaults to {} # Defaults to {}
# #
# [*repo_source_hash*] # [*repo_source_hash*]
# (optional) A hash of repo files # (Optional) A hash of repo files.
# Defaults to {} # Defaults to {}
# #
# [*repo_replace*] # [*repo_replace*]
# (optional) Replace repo files when their contents are changed # (Optional) Replace repo files when their contents are changed.
# Defaults to true # Defaults to true
# #
# [*repo_defaults*] # [*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. # created using create_resource.
# Defaults to $::openstack_extras::repo::redhat::params::repo_defaults # Defaults to $openstack_extras::repo::redhat::params::repo_defaults
# #
# [*gpgkey_hash*] # [*gpgkey_hash*]
# (optional) A hash of file resources that will be passed to # (Optional) A hash of file resources that will be passed to
# create_resource. See examples folder for some useful examples. # create_resources. See examples folder for some useful examples.
# Defaults to {} # Defaults to {}
# #
# [*gpgkey_defaults*] # [*gpgkey_defaults*]
# (optional) The default resource attributes to # (Optional) The default resource attributes to create gpgkeys with.
# create gpgkeys with. # Defaults to $openstack_extras::repo::redhat::params::gpgkey_defaults
# Defaults to $::openstack_extras::repo::redhat::params::gpgkey_defaults
# #
# [*purge_unmanaged*] # [*purge_unmanaged*]
# (optional) Purge the yum.repos.d directory of # (Optional) Purge the yum.repos.d directory of all repositories
# all repositories not managed by Puppet # not managed by Puppet.
# Defaults to false # Defaults to false
# #
# [*package_require*] # [*package_require*]
# (optional) Set all packages to require all # (Optional) Set all packages to require all yumrepos be set.
# yumrepos be set.
# Defaults to false # 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*] # [*centos_mirror_url*]
# (optional) URL of CentOS mirror. # (Optional) URL of CentOS mirror.
# Defaults to 'http://mirror.centos.org' # Defaults to 'http://mirror.centos.org'
# #
# [*update_packages*] # [*update_packages*]
# (optional) Whether to update all packages after yum repositories are # (Optional) Whether to update all packages after yum repositories are
# configured. # configured.
# Defaults to false # Defaults to false
# #
# [*stream*] # [*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 # Defaults to true
# #
class openstack_extras::repo::redhat::redhat( # DEPRECATED PARAMS
$release = $::openstack_extras::repo::redhat::params::release, # =================
#
# [*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_rdo = true,
$manage_virt = true, $manage_virt = true,
$manage_epel = false, $manage_epel = false,
@ -95,10 +95,11 @@ class openstack_extras::repo::redhat::redhat(
$gpgkey_defaults = {}, $gpgkey_defaults = {},
$purge_unmanaged = false, $purge_unmanaged = false,
$package_require = false, $package_require = false,
$manage_priorities = true,
$centos_mirror_url = 'http://mirror.centos.org', $centos_mirror_url = 'http://mirror.centos.org',
$update_packages = false, $update_packages = false,
$stream = true, $stream = true,
# DEPRECATED PARAMS
$manage_priorities = undef,
) inherits openstack_extras::repo::redhat::params { ) inherits openstack_extras::repo::redhat::params {
validate_legacy(String, 'validate_string', $release) 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(Hash, 'validate_hash', $gpgkey_defaults)
validate_legacy(Boolean, 'validate_bool', $purge_unmanaged) validate_legacy(Boolean, 'validate_bool', $purge_unmanaged)
validate_legacy(Boolean, 'validate_bool', $package_require) validate_legacy(Boolean, 'validate_bool', $package_require)
validate_yum_hash($repo_hash)
$_repo_defaults = merge($::openstack_extras::repo::redhat::params::repo_defaults, $repo_defaults) if $manage_priorities != undef {
$_gpgkey_defaults = merge($::openstack_extras::repo::redhat::params::gpgkey_defaults, $gpgkey_defaults) 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 ? { $centos_major = $stream ? {
true => "${os_major}-stream", true => "${facts['os']['release']['major']}-stream",
default => $os_major default => $facts['os']['release']['major']
} }
anchor { 'openstack_extras_redhat': } 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' '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) create_resources('yumrepo', $rdo_hash, $_repo_defaults)
} }
if $manage_virt and ($::operatingsystem != 'Fedora') { if $manage_virt and ($facts['os']['name'] != 'Fedora') {
if $stream {
if Integer.new($os_major) >= 8 { $virt_baseurl = "${centos_mirror_url}/centos/${centos_major}/virt/\$basearch/advancedvirt-common/"
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/"
}
} else { } 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 = { $virt_hash = {
'rdo-qemu-ev' => { 'rdo-qemu-ev' => {
'baseurl' => $virt_baseurl, 'baseurl' => $virt_baseurl,
'descr' => "RDO CentOS-${$centos_major} - QEMU EV", 'descr' => "RDO CentOS-${$centos_major} - QEMU EV",
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization', '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' '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) create_resources('yumrepo', $virt_hash, $_repo_defaults)
} }
if $manage_epel { if ($manage_epel and $facts['os']['name'] != 'Fedora') {
if ($::osfamily == 'RedHat' and $epel_hash = {
$::operatingsystem != 'Fedora') 'epel' => {
{ 'metalink' => "https://mirrors.fedoraproject.org/metalink?repo=epel-${facts['os']['release']['major']}&arch=\$basearch",
$epel_hash = { 'epel' => { 'descr' => "Extra Packages for Enterprise Linux ${facts['os']['release']['major']} - \$basearch",
'metalink' => "https://mirrors.fedoraproject.org/metalink?repo=epel-${::operatingsystemmajrelease}&arch=\$basearch", 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${facts['os']['release']['major']}",
'descr' => "Extra Packages for Enterprise Linux ${::operatingsystemmajrelease} - \$basearch", 'failovermethod' => 'priority'
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::operatingsystemmajrelease}",
'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('yumrepo', $repo_hash, $_repo_defaults)
create_resources('file', $gpgkey_hash, $_gpgkey_defaults) create_resources('file', $gpgkey_hash, $_gpgkey_defaults)
$repo_source_hash.each | $filename, $url | { $repo_source_hash.each |$filename, $url| {
file { $filename: file { $filename:
path => "/etc/yum.repos.d/${filename}", path => "/etc/yum.repos.d/${filename}",
source => $url, source => $url,
notify => Exec['yum_refresh'],
replace => $repo_replace, replace => $repo_replace,
notify => Exec['yum_refresh'],
} }
} }
if ((versioncmp($::puppetversion, '3.5') > 0) and $purge_unmanaged) { if $purge_unmanaged {
resources { 'yumrepo': purge => true } 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 $package_require { if $package_require {
Yumrepo<||> -> Package<||> Yumrepo<||> -> Package<||>
}
if ($::operatingsystem == 'Fedora') or (Integer.new($os_major) >= 8) {
$yum_command = 'dnf'
} else {
$yum_command = 'yum'
} }
exec { 'yum_refresh': exec { 'yum_refresh':
command => "/usr/bin/${yum_command} clean all", command => '/usr/bin/dnf clean all',
refreshonly => true, refreshonly => true,
} }
if $update_packages { if $update_packages {
exec { 'yum_update': exec { 'yum_update':
command => "/usr/bin/${yum_command} update -y", command => '/usr/bin/dnf update -y',
refreshonly => true, refreshonly => true,
timeout => 600, timeout => 600,
} }
Exec['yum_refresh'] ~> Exec['yum_update'] -> Package <||> Exec['yum_refresh'] ~> Exec['yum_update'] -> Package <||>
} }
else { 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 describe 'openstack_extras::repo::redhat::redhat' do
shared_examples '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 context 'with default parameters' do
let :params do it { should contain_anchor('openstack_extras_redhat') }
{}
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_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud').with( 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', :source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-CentOS-SIG-Cloud',
:owner => 'root', :owner => 'root',
:group => 'root', :group => 'root',
:mode => '0644', :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( 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', :owner => 'root',
:group => 'root', :group => 'root',
:mode => '0644', :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( it { should contain_yumrepo('rdo-qemu-ev').with(
:baseurl => "http://mirror.centos.org/centos/8-stream/virt/$basearch/advancedvirt-common/", :baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/virt/$basearch/advancedvirt-common/",
:descr => 'RDO CentOS-8-stream - QEMU EV', :descr => "RDO CentOS-#{facts[:operatingsystemmajrelease]}-stream - QEMU EV",
:gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization', :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization',
:enabled => '1', :enabled => '1',
:gpgcheck => '1', :gpgcheck => '1',
:mirrorlist => 'absent', :mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]', :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 end
context 'with major release 8' do context 'with stream is false' 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
let :params do let :params do
default_params.merge!( :stream => false ) {
end :manage_rdo => true,
:manage_virt => true,
before do :stream => false,
facts.merge!( :os => {'release' => {'major' => 8}} ) }
end end
it { should contain_yumrepo('rdo-release').with( 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( 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 end
context 'with overridden release' do context 'with overridden release' do
let :params do let :params do
default_params.merge!({ :release => 'juno' }) {
:release => 'juno',
:manage_rdo => true,
}
end end
it { should contain_yumrepo('rdo-release').with( 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', :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 end
context 'with overridden repo hash' do context 'with overridden repo_hash and gpgkey_hash' do
let :params do let :params do
default_params.merge!({ :repo_hash => { {
'CentOS-Base' => { :repo_hash => {
'baseurl' => 'http://mymirror/$releasever/os/$basearch/', 'CentOS-Base' => {
'descr' => 'CentOS-$releasever - Base', 'baseurl' => 'http://mymirror/$releasever/os/$basearch/',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6' 'descr' => 'CentOS-$releasever - Base',
}, 'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS',
'CentOS-Updates' => { },
'baseurl' => 'http://mymirror/$releasever/updates/$basearch/', 'CentOS-Updates' => {
'descr' => 'CentOS-$releasever - Updates', 'baseurl' => 'http://mymirror/$releasever/updates/$basearch/',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6', '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 end
it { should contain_yumrepo('CentOS-Base').with( it { should contain_yumrepo('CentOS-Base').with(
:baseurl => "http://mymirror/$releasever/os/$basearch/", :baseurl => 'http://mymirror/$releasever/os/$basearch/',
:descr => "CentOS-$releasever - Base", :descr => 'CentOS-$releasever - Base',
:enabled => '1', :enabled => '1',
:gpgcheck => '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', :mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]', :require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)} )}
it { should contain_yumrepo('CentOS-Updates').with( it { should contain_yumrepo('CentOS-Updates').with(
@ -184,111 +182,177 @@ describe 'openstack_extras::repo::redhat::redhat' do
:descr => "CentOS-$releasever - Updates", :descr => "CentOS-$releasever - Updates",
:enabled => '1', :enabled => '1',
:gpgcheck => '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', :mirrorlist => 'absent',
:notify => 'Exec[yum_refresh]',
:require => 'Anchor[openstack_extras_redhat]', :require => 'Anchor[openstack_extras_redhat]',
:notify => 'Exec[yum_refresh]'
)} )}
end
context 'with overridden repo default' do it { should contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-Something').with(
let :params do :source => 'puppet:///modules/openstack_extras/RPM-GPG-KEY-Something',
default_params.merge!({ :repo_defaults => { :owner => 'root',
'proxy' => 'http://my.proxy.com:8000' :group => 'root',
}, :mode => '0644',
:centos_mirror_url => 'http://mirror.dfw.rax.openstack.org', :before => 'Anchor[openstack_extras_redhat]',
})
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'
)} )}
end 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 context 'with repo_source_hash' do
let :params do let :params do
default_params.merge!({ {
:repo_source_hash => { :repo_source_hash => {
'delorean.repo' => 'https://trunk.rdoproject.org/centos8-master/puppet-passed-ci/delorean.repo', 'delorean.repo' => 'https://trunk.rdoproject.org/centos/puppet-passed-ci/delorean.repo',
'delorean-deps.repo' => 'https://trunk.rdoproject.org/centos8-master/delorean-deps.repo'}}) 'delorean-deps.repo' => 'https://trunk.rdoproject.org/centos/delorean-deps.repo',
},
}
end end
it { it { should contain_file('delorean.repo').with(
should contain_file('delorean.repo').with( :path => '/etc/yum.repos.d/delorean.repo',
:path => '/etc/yum.repos.d/delorean.repo', :source => 'https://trunk.rdoproject.org/centos/puppet-passed-ci/delorean.repo',
:source => 'https://trunk.rdoproject.org/centos8-master/puppet-passed-ci/delorean.repo' :replace => true,
) :notify => 'Exec[yum_refresh]',
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-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
end end
@ -297,11 +361,7 @@ describe 'openstack_extras::repo::redhat::redhat' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts({ :operatingsystem => 'RedHat', facts.merge!(OSDefaults.get_facts())
:operatingsystemrelease => '7.1',
:operatingsystemmajrelease => '7',
:os => {'release' => {'major' => '7'}},
:puppetversion => Puppet.version }))
end end
if facts[:osfamily] == 'RedHat' if facts[:osfamily] == 'RedHat'