Replace legacy facts and use fact hash

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

Change-Id: If81712ed2129684d887668f6320e88a206fdad4b
This commit is contained in:
Takashi Kajinami
2023-03-01 13:54:10 +09:00
parent 66dc9289fc
commit 62439012bd
10 changed files with 21 additions and 28 deletions

View File

@@ -2,7 +2,7 @@ Exec { logoutput => 'on_failure' }
include openstacklib::defaults include openstacklib::defaults
if $::osfamily == 'RedHat' { if $facts['os']['family'] == 'RedHat' {
# Virtual package name, present in @base. # Virtual package name, present in @base.
package { 'perl(Net::HTTP)': package { 'perl(Net::HTTP)':
ensure => present, ensure => present,

View File

@@ -5,7 +5,7 @@ Puppet::Type.type(:policy_rcd).provide(:policy_rcd) do
mk_resource_methods mk_resource_methods
def check_os def check_os
Facter.value(:osfamily) == 'Debian' Facter.value(:os)['family'] == 'Debian'
end end
def check_policy_rcd def check_policy_rcd

View File

@@ -5,7 +5,7 @@
# This file is loaded in the params.pp of each class. # This file is loaded in the params.pp of each class.
# #
class openstacklib::defaults { class openstacklib::defaults {
case $::osfamily { case $facts['os']['family'] {
'RedHat': { 'RedHat': {
$pyver3 = '3.9' $pyver3 = '3.9'
} }
@@ -13,7 +13,7 @@ class openstacklib::defaults {
$pyver3 = '3' $pyver3 = '3'
} }
default:{ default:{
fail("Unsupported osfamily: ${::osfamily}") fail("Unsupported osfamily: ${facts['os']['family']}")
} }
} }
} }

View File

@@ -9,7 +9,7 @@ class openstacklib::params {
$openstackclient_package_name = 'python3-openstackclient' $openstackclient_package_name = 'python3-openstackclient'
case $::osfamily { case $facts['os']['family'] {
'RedHat': { 'RedHat': {
$open_iscsi_package_name = 'iscsi-initiator-utils' $open_iscsi_package_name = 'iscsi-initiator-utils'
} }
@@ -17,8 +17,7 @@ class openstacklib::params {
$open_iscsi_package_name = 'open-iscsi' $open_iscsi_package_name = 'open-iscsi'
} }
default:{ default:{
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ fail("Unsupported osfamily: ${facts['os']['family']}")
module ${module_name} only support osfamily RedHat and Debian")
} }
} }
} }

View File

@@ -27,7 +27,7 @@ class openstacklib::policyrcd(
validate_legacy(Array, 'validate_array', $services) validate_legacy(Array, 'validate_array', $services)
if $::osfamily == 'Debian' { if $facts['os']['family'] == 'Debian' {
# We put this out there so openstack services wont auto start # We put this out there so openstack services wont auto start
# when installed. # when installed.
file { '/usr/sbin/policy-rc.d': file { '/usr/sbin/policy-rc.d':

View File

@@ -29,7 +29,7 @@
# #
# [*servername*] # [*servername*]
# (Optional) The servername for the virtualhost # (Optional) The servername for the virtualhost
# Defaults to $::fqdn # Defaults to $facts['networking']['fqdn']
# #
# [*bind_host*] # [*bind_host*]
# (Optional) The host/ip address Apache will listen on. # (Optional) The host/ip address Apache will listen on.
@@ -102,7 +102,7 @@
# #
# [*workers*] # [*workers*]
# (Optional) The number of workers for the vhost. # (Optional) The number of workers for the vhost.
# Defaults to $::os_workers # Defaults to $facts['os_workers']
# #
# [*wsgi_daemon_process*] # [*wsgi_daemon_process*]
# (Optional) Name of the WSGI daemon process. # (Optional) Name of the WSGI daemon process.
@@ -238,7 +238,7 @@
# #
define openstacklib::wsgi::apache ( define openstacklib::wsgi::apache (
$service_name = $name, $service_name = $name,
$servername = $::fqdn, $servername = $facts['networking']['fqdn'],
$bind_host = undef, $bind_host = undef,
$bind_port = undef, $bind_port = undef,
$group = undef, $group = undef,
@@ -256,7 +256,7 @@ define openstacklib::wsgi::apache (
$ssl_verify_client = undef, $ssl_verify_client = undef,
$threads = 1, $threads = 1,
$user = undef, $user = undef,
$workers = $::os_workers, $workers = $facts['os_workers'],
$wsgi_daemon_process = $name, $wsgi_daemon_process = $name,
$wsgi_process_display_name = $name, $wsgi_process_display_name = $name,
$wsgi_process_group = $name, $wsgi_process_group = $name,

View File

@@ -32,7 +32,7 @@ describe 'openstacklib::iscsid' do
end end
let(:platform_params) do let(:platform_params) do
case facts[:osfamily] case facts[:os]['family']
when 'Debian' when 'Debian'
{ :open_iscsi_package_name => 'open-iscsi' } { :open_iscsi_package_name => 'open-iscsi' }
when 'RedHat' when 'RedHat'

View File

@@ -32,7 +32,7 @@ describe 'openstacklib::openstackclient' do
end end
let(:platform_params) do let(:platform_params) do
case facts[:osfamily] case facts[:os]['family']
when 'Debian' when 'Debian'
{ :openstackclient_package_name => 'python3-openstackclient' } { :openstackclient_package_name => 'python3-openstackclient' }
when 'RedHat' when 'RedHat'

View File

@@ -93,7 +93,7 @@ eof
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_behaves_like "openstacklib::policyrcd on #{facts[:osfamily]} platforms" it_behaves_like "openstacklib::policyrcd on #{facts[:os]['family']} platforms"
end end
end end
end end

View File

@@ -20,14 +20,6 @@ require 'spec_helper'
describe 'openstacklib::wsgi::apache' do describe 'openstacklib::wsgi::apache' do
let (:title) { 'keystone_wsgi' } let (:title) { 'keystone_wsgi' }
let :global_facts do
{
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld'
}
end
let :params do let :params do
{ {
:bind_port => 5000, :bind_port => 5000,
@@ -66,7 +58,7 @@ describe 'openstacklib::wsgi::apache' do
)} )}
it { should contain_apache__vhost('keystone_wsgi').with( it { should contain_apache__vhost('keystone_wsgi').with(
:servername => 'some.host.tld', :servername => 'foo.example.com',
:ip => nil, :ip => nil,
:port => '5000', :port => '5000',
:docroot => '/var/www/cgi-bin/keystone', :docroot => '/var/www/cgi-bin/keystone',
@@ -79,7 +71,7 @@ describe 'openstacklib::wsgi::apache' do
'keystone_wsgi' => { 'keystone_wsgi' => {
'user' => 'keystone', 'user' => 'keystone',
'group' => 'keystone', 'group' => 'keystone',
'processes' => global_facts[:os_workers], 'processes' => facts[:os_workers],
'threads' => 1, 'threads' => 1,
'display-name' => 'keystone_wsgi', 'display-name' => 'keystone_wsgi',
}}, }},
@@ -190,7 +182,7 @@ describe 'openstacklib::wsgi::apache' do
'keystone_wsgi' => { 'keystone_wsgi' => {
'user' => 'someotheruser', 'user' => 'someotheruser',
'group' => 'someothergroup', 'group' => 'someothergroup',
'processes' => global_facts[:os_workers], 'processes' => facts[:os_workers],
'threads' => 1, 'threads' => 1,
'display-name' => 'keystone_wsgi', 'display-name' => 'keystone_wsgi',
'python_path' => '/my/python/admin/path', 'python_path' => '/my/python/admin/path',
@@ -259,11 +251,13 @@ describe 'openstacklib::wsgi::apache' 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(global_facts)) facts.merge!(OSDefaults.get_facts({
:os_workers => 8,
}))
end end
let(:platform_params) do let(:platform_params) do
case facts[:osfamily] case facts[:os]['family']
when 'Debian' when 'Debian'
{ {
:httpd_service_name => 'apache2', :httpd_service_name => 'apache2',