Replace legacy facts and use fact hash

... because the latest lint no longer allows usage of legacy facts and
top scope fact.

Change-Id: I3eb492be8b2eba3261e7662f651681f6c63887c4
This commit is contained in:
Takashi Kajinami 2023-03-01 15:33:49 +09:00
parent 6f0628bf3f
commit 42f02f64fe
7 changed files with 39 additions and 43 deletions

View File

@ -38,7 +38,7 @@
#
# [*deb_location*]
# (optional) Debian package repository location.
# Defaults to "http://${::lsbdistcodename}-${release}.debian.net/debian"
# Defaults to "http://${facts['os']['distro']['codename']}-${release}.debian.net/debian"
#
class openstack_extras::repo::debian::debian(
$release = $::openstack_extras::repo::debian::params::release,
@ -48,7 +48,7 @@ class openstack_extras::repo::debian::debian(
# Below params only used if $use_extrepo is set to false
$source_hash = {},
$source_defaults = {},
$deb_location = "http://${::lsbdistcodename}-${release}.debian.net/debian",
$deb_location = "http://${facts['os']['distro']['codename']}-${release}.debian.net/debian",
) inherits openstack_extras::repo::debian::params {
$lowercase_release = downcase($release)
@ -98,12 +98,12 @@ apt-get update
}
apt::source { $::openstack_extras::repo::debian::params::deb_name:
location => $deb_location,
release => "${::lsbdistcodename}-${lowercase_release}-backports",
release => "${facts['os']['distro']['codename']}-${lowercase_release}-backports",
repos => $::openstack_extras::repo::debian::params::deb_repos,
}
-> apt::source { "${::openstack_extras::repo::debian::params::deb_name}-nochange":
location => $deb_location,
release => "${::lsbdistcodename}-${lowercase_release}-backports-nochange",
release => "${facts['os']['distro']['codename']}-${lowercase_release}-backports-nochange",
repos => $::openstack_extras::repo::debian::params::deb_repos,
}
}

View File

@ -62,7 +62,7 @@ class openstack_extras::repo::debian::ubuntu(
}
apt::source { $::openstack_extras::repo::debian::params::uca_name:
location => $uca_location,
release => "${::lsbdistcodename}-${repo}/${release}",
release => "${facts['os']['distro']['codename']}-${repo}/${release}",
repos => $::openstack_extras::repo::debian::params::uca_repos,
}
}

View File

@ -123,7 +123,7 @@ class openstack_extras::repo::redhat::redhat (
# NOTE(tobias-urdin): This was introduced in yumrepo_core 1.0.7 which is
# included from 6.15.0 and forward (also since 7.0.0).
# TODO(tobias-urdin): Should set this by default when we only support Puppet 7.
if versioncmp($::puppetversion, '6.15.0') >= 0 {
if versioncmp($facts['puppetversion'], '6.15.0') >= 0 {
Yumrepo<| title == 'rdo-release' |> {
module_hotfixes => true,
}

View File

@ -58,14 +58,14 @@ apt-get update
end
it { should contain_apt__source('debian-openstack-backports').with(
:location => 'http://stretch-zed.debian.net/debian',
:release => 'stretch-zed-backports',
:location => 'http://bullseye-zed.debian.net/debian',
:release => 'bullseye-zed-backports',
:repos => 'main',
)}
it { should contain_apt__source('debian-openstack-backports-nochange').with(
:location => 'http://stretch-zed.debian.net/debian',
:release => 'stretch-zed-backports-nochange',
:location => 'http://bullseye-zed.debian.net/debian',
:release => 'bullseye-zed-backports-nochange',
:repos => 'main'
)}
@ -78,21 +78,21 @@ apt-get update
end
it { should contain_apt__source('debian-openstack-backports').with(
:location => 'http://stretch-pike.debian.net/debian',
:release => 'stretch-pike-backports',
:location => 'http://bullseye-pike.debian.net/debian',
:release => 'bullseye-pike-backports',
:repos => 'main',
)}
it { should contain_apt__source('debian-openstack-backports-nochange').with(
:location => 'http://stretch-pike.debian.net/debian',
:release => 'stretch-pike-backports-nochange',
:location => 'http://bullseye-pike.debian.net/debian',
:release => 'bullseye-pike-backports-nochange',
:repos => 'main'
)}
it { should contain_exec('installing openstack-backports-archive-keyring') }
end
context 'when not managing stretch repo' do
context 'when not managing bullseye repo' do
let :params do
default_params.merge!({ :manage_deb => false })
end
@ -111,7 +111,7 @@ apt-get update
'puppetlabs' => {
'location' => 'http://apt.puppetlabs.com',
'repos' => 'main',
'release' => 'stretch',
'release' => 'bullseye',
'key' => {
'id' => '4BD6EC30', 'server' => 'pgp.mit.edu'
}
@ -130,7 +130,7 @@ apt-get update
it { should contain_apt__source('puppetlabs').with(
:location => 'http://apt.puppetlabs.com',
:repos => 'main',
:release => 'stretch',
:release => 'bullseye',
:key => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' },
)}
@ -170,12 +170,10 @@ apt-get update
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :lsbdistid => 'Debian',
:lsbdistcodename => 'stretch',
:lsbdistrelease => '9' }))
facts.merge!(OSDefaults.get_facts())
end
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] == 'Debian'
if facts[:os]['name'] == 'Debian'
it_behaves_like 'openstack_extras::repo::debian::debian'
end
end

View File

@ -28,7 +28,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do
it { should contain_apt__source('ubuntu-cloud-archive').with(
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
:release => 'trusty-updates/zed',
:release => 'jammy-updates/zed',
:repos => 'main',
)}
@ -42,7 +42,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do
it { should contain_apt__source('ubuntu-cloud-archive').with(
:location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
:release => 'trusty-updates/juno',
:release => 'jammy-updates/juno',
:repos => 'main',
)}
@ -63,12 +63,12 @@ describe 'openstack_extras::repo::debian::ubuntu' do
'local_mirror' => {
'location' => 'http://mymirror/ubuntu/',
'repos' => 'main',
'release' => 'trusty'
'release' => 'jammy'
},
'puppetlabs' => {
'location' => 'http://apt.puppetlabs.com',
'repos' => 'main',
'release' => 'trusty',
'release' => 'jammy',
'key' => {
'id' => '4BD6EC30', 'server' => 'pgp.mit.edu'
}
@ -79,13 +79,13 @@ describe 'openstack_extras::repo::debian::ubuntu' do
it { should contain_apt__source('local_mirror').with(
:location => 'http://mymirror/ubuntu/',
:release => 'trusty',
:release => 'jammy',
:repos => 'main'
)}
it { should contain_apt__source('puppetlabs').with(
:location => 'http://apt.puppetlabs.com',
:release => 'trusty',
:release => 'jammy',
:repos => 'main',
:key => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' }
)}
@ -99,7 +99,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do
'local_mirror' => {
'location' => 'http://mymirror/ubuntu/',
'repos' => 'main',
'release' => 'trusty'
'release' => 'jammy'
}
}
})
@ -112,7 +112,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do
it { should contain_apt__source('local_mirror').with(
:include => { 'src' => true },
:location => 'http://mymirror/ubuntu/',
:release => 'trusty',
:release => 'jammy',
:repos => 'main',
)}
@ -127,7 +127,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do
it { should contain_apt__source('ubuntu-cloud-archive').with(
:location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive',
:release => 'trusty-proposed/zed',
:release => 'jammy-proposed/zed',
:repos => 'main',
)}
end
@ -138,12 +138,10 @@ describe 'openstack_extras::repo::debian::ubuntu' do
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :lsbdistid => 'Ubuntu',
:lsbdistcodename => 'trusty',
:lsbdistrelease => '14.04' }))
facts.merge!(OSDefaults.get_facts())
end
if facts[:operatingsystem] == 'Ubuntu'
if facts[:os]['name'] == 'Ubuntu'
it_behaves_like 'openstack_extras::repo::debian::ubuntu'
end
end

View File

@ -24,7 +24,7 @@ describe 'openstack_extras::repo::redhat::redhat' do
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should_not contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}") }
it { should_not contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:os]['release']['major']}") }
it { should_not contain_yumrepo('epel') }
it { should_not contain_resources('yumrepo').with_purge(true) }
@ -53,8 +53,8 @@ describe 'openstack_extras::repo::redhat::redhat' do
it { should_not contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud') }
it { should_not contain_yumrepo('rdo-release') }
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]}",
it { should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:os]['release']['major']}").with(
:source => "puppet:///modules/openstack_extras/RPM-GPG-KEY-EPEL-#{facts[:os]['release']['major']}",
:owner => 'root',
:group => 'root',
:mode => '0644',
@ -62,9 +62,9 @@ describe 'openstack_extras::repo::redhat::redhat' do
)}
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]}",
: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',
:enabled => '1',
:gpgcheck => '1',
@ -168,7 +168,7 @@ describe 'openstack_extras::repo::redhat::redhat' do
:require => 'Anchor[openstack_extras_redhat]',
)}
it { should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}").with(
it { should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:os]['release']['major']}").with(
:owner => 'steve',
:group => 'root',
:mode => '0644',
@ -309,7 +309,7 @@ describe 'openstack_extras::repo::redhat::redhat' do
facts.merge!(OSDefaults.get_facts())
end
if facts[:osfamily] == 'RedHat'
if facts[:os]['family'] == 'RedHat'
it_behaves_like 'openstack_extras::repo::redhat::redhat'
end
end

View File

@ -133,7 +133,7 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
facts.merge!(OSDefaults.get_facts())
end
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] == 'Debian'
if facts[:os]['name'] == 'Debian'
it_behaves_like 'openstack_extras::pacemaker::service'
end
end