CentOS 8 support

- Add yum-centos cookbook to deps
  - Enable PowerTools and RabbitMQ repositories on EL8
- Update various packages for EL8

Depends-On: https://review.opendev.org/c/openstack/openstack-chef/+/814234
Change-Id: Ife3165204d9ffee132a0daacd4a6f30c7d31378b
Signed-off-by: Lance Albertson <lance@osuosl.org>
This commit is contained in:
Lance Albertson 2021-10-15 15:08:36 -07:00
parent d50c4ad40d
commit df9900d25b
8 changed files with 192 additions and 111 deletions

View File

@ -43,6 +43,7 @@ The following cookbooks are dependencies:
- 'mariadb', '~> 5.0'
- 'memcached', '~> 7.0'
- 'selinux'
- 'yum-centos', '>= 3.2.0'
- 'yum-epel'
Attributes

View File

@ -122,9 +122,15 @@ default['openstack']['db']['python_packages'] = {
case node['platform_family']
when 'rhel'
default['openstack']['db']['service_type'] = 'mariadb'
default['openstack']['db']['python_packages']['mariadb'] = ['MySQL-python']
default['openstack']['db']['python_packages']['percona-cluster'] = ['MySQL-python']
default['openstack']['db']['python_packages']['galera'] = ['MySQL-python']
if node['platform_version'].to_i >= 8
default['openstack']['db']['python_packages']['mariadb'] = ['python3-PyMySQL']
default['openstack']['db']['python_packages']['percona-cluster'] = ['python3-PyMySQL']
default['openstack']['db']['python_packages']['galera'] = ['python3-PyMySQL']
else
default['openstack']['db']['python_packages']['mariadb'] = ['MySQL-python']
default['openstack']['db']['python_packages']['percona-cluster'] = ['MySQL-python']
default['openstack']['db']['python_packages']['galera'] = ['MySQL-python']
end
when 'debian'
default['openstack']['db']['service_type'] = 'mariadb'
default['openstack']['db']['python_packages']['mariadb'] = ['python3-mysqldb']

View File

@ -292,18 +292,34 @@ default['openstack']['sysctl']['net.ipv4.conf.default.rp_filter'] = 0
case node['platform_family']
when 'rhel'
default['openstack']['common']['platform'] = {
'common_client_packages' => ['python-openstackclient'],
'python_packages' => %w(
python
python2-pip
python2-setuptools
python-devel
python-virtualenv
python-wheel
),
'package_overrides' => '',
}
default['openstack']['common']['platform'] =
if node['platform_version'].to_i >= 8
{
'common_client_packages' => ['python3-openstackclient'],
'python_packages' => %w(
python3-pip
python3-setuptools
python3-virtualenv
python3-wheel
python36
python36-devel
),
'package_overrides' => '',
}
else
{
'common_client_packages' => ['python-openstackclient'],
'python_packages' => %w(
python
python2-pip
python2-setuptools
python-devel
python-virtualenv
python-wheel
),
'package_overrides' => '',
}
end
when 'debian'
default['openstack']['common']['platform'] = {
'common_client_packages' => ['python3-openstackclient'],

View File

@ -13,6 +13,7 @@ depends 'etcd', '~> 7.0'
depends 'mariadb', '~> 5.0'
depends 'memcached', '~> 7.0'
depends 'selinux'
depends 'yum-centos', '>= 3.2.0'
depends 'yum-epel'
issues_url 'https://launchpad.net/openstack-chef'

View File

@ -72,8 +72,20 @@ when 'debian'
end
when 'rhel'
# TODO(ramereth): These packages conflict with the RDO repo for Train
node.default['yum']['epel']['exclude'] = 'python2-qpid-proton python2-pyngus qpid-proton-c'
case node['platform_version'].to_i
when 7
# TODO(ramereth): These packages conflict with the RDO repo for Train
node.default['yum']['epel']['exclude'] = 'python2-qpid-proton python2-pyngus qpid-proton-c'
when 8
# Need PowerTools repo for some of the python deps
node.default['yum']['powertools']['enabled'] = true
node.default['yum']['powertools']['managed'] = true
# Need to use RabbitMQ repo on EL8
node.default['yum']['centos-rabbitmq']['enabled'] = true
node.default['yum']['centos-rabbitmq']['managed'] = true
include_recipe 'yum-centos'
end
include_recipe 'yum-epel'
@ -111,7 +123,7 @@ when 'rhel'
package 'centos-release-qemu-ev' do
action :upgrade
end
end if node['platform_version'].to_i < 8
end
# install a python

View File

@ -1,19 +1,28 @@
require_relative 'spec_helper'
describe 'openstack-common::client' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
cached(:chef_run) do
runner.converge(described_recipe)
end
ALL_RHEL.each do |p|
context "redhat #{p[:version]}" do
let(:runner) { ChefSpec::SoloRunner.new(p) }
let(:node) { runner.node }
cached(:chef_run) do
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it do
expect(chef_run).to upgrade_package('python-openstackclient')
case p
when REDHAT_7
it do
expect(chef_run).to upgrade_package('python-openstackclient')
end
when REDHAT_8
it do
expect(chef_run).to upgrade_package('python3-openstackclient')
end
end
end
end
end

View File

@ -1,109 +1,135 @@
require_relative 'spec_helper'
describe 'openstack-common::default' do
describe 'rhel-rdo' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
runner.converge(described_recipe)
end
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it do
expect(chef_run).to upgrade_package('centos-release-qemu-ev')
end
pkgs = %w(python python2-pip python2-setuptools python-devel python-virtualenv python-wheel)
it 'installs python2 packages' do
expect(chef_run).to upgrade_package(pkgs)
end
context 'enabling RDO with gpgcheck enabled' do
ALL_RHEL.each do |p|
context "redhat #{p[:version]}" do
let(:runner) { ChefSpec::SoloRunner.new(p) }
let(:node) { runner.node }
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = true
node.override['openstack']['yum']['gpgcheck'] = true
runner.converge(described_recipe)
end
it 'adds RDO yum repository' do
# Using cookbook(yum) LWRP custom matcher
# https://github.com/sethvargo/chefspec#packaging-custom-matchers
expect(chef_run).to add_yum_repository('RDO-testrelease')
.with(gpgcheck: true)
it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
it 'does include yum-epel recipe' do
expect(chef_run).to include_recipe('yum-epel')
end
end
case p
when REDHAT_7
pkgs = %w(python python2-pip python2-setuptools python-devel python-virtualenv python-wheel)
context 'enabling RDO with gpgcheck disabled' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = true
node.override['openstack']['yum']['gpgcheck'] = false
runner.converge(described_recipe)
it do
expect(chef_run).to upgrade_package('centos-release-qemu-ev')
end
it do
expect(chef_run).to include_recipe('yum-epel')
end
it do
expect(chef_run).to_not include_recipe('yum-centos')
end
it do
expect(chef_run).to create_yum_repository('epel').with(
exclude: 'python2-qpid-proton python2-pyngus qpid-proton-c'
)
end
when REDHAT_8
pkgs = %w(python3-pip python3-setuptools python3-virtualenv python3-wheel python36 python36-devel)
it do
expect(chef_run).to_not upgrade_package('centos-release-qemu-ev')
end
%w(yum-epel yum-centos).each do |r|
it do
expect(chef_run).to include_recipe(r)
end
end
it do
expect(chef_run).to create_yum_repository('epel').with(exclude: nil)
end
%w(powertools centos-rabbitmq).each do |repo|
it do
expect(chef_run).to create_yum_repository(repo).with(enabled: true)
end
end
end
it 'adds RDO yum repository' do
expect(chef_run).to add_yum_repository('RDO-testrelease')
.with(gpgcheck: false)
it do
expect(chef_run).to upgrade_package(pkgs)
end
it 'does include yum-epel recipe' do
expect(chef_run).to include_recipe('yum-epel')
end
end
context 'enabling RDO with gpgcheck enabled' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = true
node.override['openstack']['yum']['gpgcheck'] = true
runner.converge(described_recipe)
end
context 'disabling RDO deps repo with is_release true' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['is_release'] = true
runner.converge(described_recipe)
it do
expect(chef_run).to add_yum_repository('RDO-testrelease').with(gpgcheck: true)
end
end
it 'does not add the RDO deps yum repository' do
expect(chef_run).to_not add_yum_repository('RDO-testrelease-deps')
end
end
context 'enabling RDO with gpgcheck disabled' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = true
node.override['openstack']['yum']['gpgcheck'] = false
runner.converge(described_recipe)
end
context 'disabling RDO' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = false
runner.converge(described_recipe)
it do
expect(chef_run).to add_yum_repository('RDO-testrelease').with(gpgcheck: false)
end
end
it 'removes RDO yum repository' do
allow(FileTest).to receive(:exist?).and_call_original
allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true)
expect(chef_run).to remove_yum_repository('RDO-testrelease')
end
it 'does include yum-epel recipe' do
expect(chef_run).to include_recipe('yum-epel')
context 'disabling RDO deps repo with is_release true' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['is_release'] = true
runner.converge(described_recipe)
end
it 'does not add the RDO deps yum repository' do
expect(chef_run).to_not add_yum_repository('RDO-testrelease-deps')
end
end
it 'does not create RDO-Manager yum repositories' do
expect(chef_run).to_not create_remote_file('/etc/yum.repos.d/rdo-manager-release.repo')
end
end
context 'disabling RDO' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = false
runner.converge(described_recipe)
end
context 'disabling RDO and repo file does not exist' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = false
runner.converge(described_recipe)
it 'removes RDO yum repository' do
allow(FileTest).to receive(:exist?).and_call_original
allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true)
expect(chef_run).to remove_yum_repository('RDO-testrelease')
end
it 'does not create RDO-Manager yum repositories' do
expect(chef_run).to_not create_remote_file('/etc/yum.repos.d/rdo-manager-release.repo')
end
end
it 'does nothing when RDO yum repository does not exist' do
allow(FileTest).to receive(:exist?).and_call_original
allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(false)
expect(chef_run).to nothing_yum_repository('RDO-testrelease')
context 'disabling RDO and repo file does not exist' do
cached(:chef_run) do
node.override['openstack']['release'] = 'testrelease'
node.override['openstack']['yum']['rdo_enabled'] = false
runner.converge(described_recipe)
end
it 'does nothing when RDO yum repository does not exist' do
allow(FileTest).to receive(:exist?).and_call_original
allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(false)
expect(chef_run).to nothing_yum_repository('RDO-testrelease')
end
end
end
end

View File

@ -12,11 +12,21 @@ UBUNTU_OPTS = {
version: '18.04',
}.freeze
REDHAT_OPTS = {
REDHAT_7 = {
platform: 'redhat',
version: '7',
}.freeze
REDHAT_8 = {
platform: 'redhat',
version: '8',
}.freeze
ALL_RHEL = [
REDHAT_7,
REDHAT_8,
].freeze
# We set a default platform for non-platform specific test cases
CHEFSPEC_OPTS = UBUNTU_OPTS