Skip to content

Commit

Permalink
feat: node_terminus variable for server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d1nuc0m committed Nov 22, 2024
1 parent b4c69a6 commit 9422ede
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@
## 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
$primary_envs_dir = $puppet::server::envs_dir[0]

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,
}
}

Expand Down
16 changes: 12 additions & 4 deletions manifests/server/enc.pp
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
12 changes: 12 additions & 0 deletions spec/classes/puppet_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9422ede

Please sign in to comment.