From d5ca4076c4ad59bee4b656f8ee212d76fa1236c7 Mon Sep 17 00:00:00 2001 From: Francesco Di Nucci Date: Fri, 22 Nov 2024 12:25:57 +0100 Subject: [PATCH] feat: node_terminus variable for server Allow to override default value of [server]/node_terminus in puppet.conf Useful in case of standalone (non-Foreman) Puppet Server installs without an ENC. Tests are updated as now without Foreman, node terminus is explicitly set to the default 'plain' value Reference https://www.puppet.com/docs/puppet/8/configuration.html#node-terminus --- manifests/init.pp | 3 +++ manifests/params.pp | 1 + manifests/server.pp | 3 +++ manifests/server/config.pp | 9 ++++++++- manifests/server/enc.pp | 16 ++++++++++++---- spec/classes/puppet_server_spec.rb | 12 ++++++++++++ 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b91e1b27..a6f442ab 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -225,6 +225,8 @@ # # $server_reports:: List of report types to include on the puppetserver # +# $server_node_terminus:: Node data plugin for catalog compiling +# # $server_external_nodes:: External nodes classifier executable # # $server_trusted_external_command:: The external trusted facts script to use. @@ -665,6 +667,7 @@ Optional[Stdlib::Absolutepath] $server_puppetserver_rundir = $puppet::params::server_puppetserver_rundir, Optional[Stdlib::Absolutepath] $server_puppetserver_logdir = $puppet::params::server_puppetserver_logdir, Optional[Pattern[/^[\d]\.[\d]+\.[\d]+$/]] $server_puppetserver_version = $puppet::params::server_puppetserver_version, + Enum['plain', 'exec', 'classifier'] $server_node_terminus = $puppet::params::server_node_terminus, Variant[Undef, String[0], Stdlib::Absolutepath] $server_external_nodes = $puppet::params::server_external_nodes, Optional[Stdlib::Absolutepath] $server_trusted_external_command = $puppet::params::server_trusted_external_command, Array[String] $server_cipher_suites = $puppet::params::server_cipher_suites, diff --git a/manifests/params.pp b/manifests/params.pp index 38910916..8f0bbb99 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -221,6 +221,7 @@ $server_ca = true $server_ca_crl_sync = false $server_reports = 'foreman' + $server_node_terminus = 'exec' $server_external_nodes = "${dir}/node.rb" $server_trusted_external_command = undef $server_request_timeout = 60 diff --git a/manifests/server.pp b/manifests/server.pp index 33a8a41b..0e3b2291 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -58,6 +58,8 @@ # # $reports:: List of report types to include on the puppetserver # +# $node_terminus:: Node data plugin for catalog compiling +# # $external_nodes:: External nodes classifier executable # # $trusted_external_command:: The external trusted facts script to use. @@ -373,6 +375,7 @@ Optional[Stdlib::Absolutepath] $puppetserver_logdir = $puppet::server_puppetserver_logdir, Stdlib::Absolutepath $puppetserver_dir = $puppet::server_puppetserver_dir, Optional[Pattern[/^[\d]\.[\d]+\.[\d]+$/]] $puppetserver_version = $puppet::server_puppetserver_version, + Enum['plain', 'exec', 'classifier'] $node_terminus = $puppet::server_node_terminus, Variant[Undef, String[0], Stdlib::Absolutepath] $external_nodes = $puppet::server_external_nodes, Optional[Stdlib::Absolutepath] $trusted_external_command = $puppet::server_trusted_external_command, Array[String] $cipher_suites = $puppet::server_cipher_suites, diff --git a/manifests/server/config.pp b/manifests/server/config.pp index b2e47b8a..bf4001cf 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -33,6 +33,7 @@ ## General configuration $ca_server = $puppet::ca_server $ca_port = $puppet::ca_port + $server_node_terminus = $puppet::server::node_terminus $server_external_nodes = $puppet::server::external_nodes $server_environment_timeout = $puppet::server::environment_timeout $trusted_external_command = $puppet::server::trusted_external_command @@ -40,7 +41,13 @@ if $server_external_nodes and $server_external_nodes != '' { class { 'puppet::server::enc': - enc_path => $server_external_nodes, + node_terminus => $server_node_terminus, + enc_path => $server_external_nodes, + } + } + else { + class { 'puppet::server::enc': + node_terminus => $server_node_terminus, } } diff --git a/manifests/server/enc.pp b/manifests/server/enc.pp index 5b299cd8..459acdef 100644 --- a/manifests/server/enc.pp +++ b/manifests/server/enc.pp @@ -1,10 +1,18 @@ # Set up the ENC config # @api private class puppet::server::enc ( - Variant[Undef, String[0], Stdlib::Absolutepath] $enc_path = $puppet::server::external_nodes + Variant[Undef, String[0], Stdlib::Absolutepath] $enc_path = $puppet::server::external_nodes, + Enum['plain', 'exec', 'classifier'] $node_terminus = $puppet::server::node_terminus, ) { - puppet::config::server { - 'external_nodes': value => $enc_path; - 'node_terminus': value => 'exec'; + if $enc_path and $enc_path != '' { + puppet::config::server { + 'external_nodes': value => $enc_path; + 'node_terminus': value => $node_terminus; + } + } + else { + puppet::config::server { + 'node_terminus': value => $node_terminus; + } } } diff --git a/spec/classes/puppet_server_spec.rb b/spec/classes/puppet_server_spec.rb index a54c71dc..59ac11ee 100644 --- a/spec/classes/puppet_server_spec.rb +++ b/spec/classes/puppet_server_spec.rb @@ -297,6 +297,18 @@ it { should_not contain_puppet__config__server('external_nodes') } end + describe 'with plain terminus' do + let(:params) do + super().merge( + server_node_terminus: 'plain', + server_external_nodes: '' + ) + end + + it { should contain_puppet__config__server('node_terminus').with_value('plain') } + it { should_not contain_puppet__config__server('external_nodes') } + end + describe 'with server_default_manifest => true and undef content' do let(:params) do super().merge(server_default_manifest: true)