From 9b1acab8dffa2950fb25ddf335593ae66185cfb5 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 28 Mar 2024 14:28:59 -0700 Subject: [PATCH] (profile::core::node_info) fwv --- site/profile/manifests/core/common.pp | 1 + site/profile/manifests/core/node_info.pp | 22 ++++++++++++++++++++++ spec/classes/ccs/common_spec.rb | 3 ++- spec/classes/ccs/el9_spec.rb | 3 ++- spec/spec_helper.rb | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 site/profile/manifests/core/node_info.pp diff --git a/site/profile/manifests/core/common.pp b/site/profile/manifests/core/common.pp index f13c4d6c50..0768786304 100644 --- a/site/profile/manifests/core/common.pp +++ b/site/profile/manifests/core/common.pp @@ -75,6 +75,7 @@ include profile::core::kernel include profile::core::keytab include profile::core::nm_dispatch + include profile::core::node_info include profile::core::selinux include profile::core::systemd include rsyslog diff --git a/site/profile/manifests/core/node_info.pp b/site/profile/manifests/core/node_info.pp new file mode 100644 index 0000000000..2c10c559b8 --- /dev/null +++ b/site/profile/manifests/core/node_info.pp @@ -0,0 +1,22 @@ +# @summary +# This empty class exists solely as a vehicle for shipping enc data to puppetdb. +# +# Note that the facts hash does not contain enc parameters and they must be +# accessed as top scoped variables. +# +# @param site +# @param role +# @param cluster +# @param variant +# @param subvariant +# +# lint:ignore:top_scope_facts +class profile::core::node_info ( + Optional[String[1]] $site = $::site, + Optional[String[1]] $role = $::role, + Optional[String[1]] $cluster = $::cluster, + Optional[String[1]] $variant = $::variant, + Optional[String[1]] $subvariant = $::subvariant, +) { +# lint:endignore +} diff --git a/spec/classes/ccs/common_spec.rb b/spec/classes/ccs/common_spec.rb index 7ed24b7de8..c6347e188b 100644 --- a/spec/classes/ccs/common_spec.rb +++ b/spec/classes/ccs/common_spec.rb @@ -5,7 +5,8 @@ describe 'profile::ccs::common' do on_supported_os.each do |os, os_facts| context "on #{os}" do - let(:facts) { override_facts(os_facts, site: 'ls') } + let(:facts) { os_facts } + let(:node_params) { { site: 'ls' } } let(:pre_condition) do <<~PP include ssh diff --git a/spec/classes/ccs/el9_spec.rb b/spec/classes/ccs/el9_spec.rb index ed97758ab4..d0dc0254d2 100644 --- a/spec/classes/ccs/el9_spec.rb +++ b/spec/classes/ccs/el9_spec.rb @@ -7,7 +7,8 @@ next unless os =~ %r{almalinux-9-x86_64} context "on #{os}" do - let(:facts) { override_facts(os_facts, site: 'ls') } + let(:facts) { os_facts } + let(:node_params) { { site: 'ls' } } let(:pre_condition) do <<~PP include ssh diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b060984223..d47e1fc7a3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -105,6 +105,14 @@ def hiera_files_in_layer(layer) Puppet.settings[:strict] = :warning end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + # stub out enc parameters which will show up as top level variables, if set. + c.default_node_params = { + role: nil, + site: nil, + cluster: nil, + variant: nil, + subvariant: nil, + } end # Disable rspec-puppet coverage reporting which is hardwired as enabled here: @@ -419,6 +427,18 @@ def node_files it { is_expected.to contain_class('systemd').with_manage_udevd(true) } it { is_expected.to contain_class('sudo').with_purge(true) } + + # All host spec are expected to set the role & site node params. The other + # node params will vary per host spec. + it do + is_expected.to contain_class('profile::core::node_info').with( + role: node_params[:role], + site: node_params[:site], + cluster: node_params[:cluster], + variant: node_params[:variant], + subvariant: node_params[:subvariant], + ) + end end shared_examples 'lhn sysctls', :lhn_node do