Skip to content

Commit

Permalink
Fixes #25839 - Determine puppetserver version in server.pp
Browse files Browse the repository at this point in the history
Currently we store some parameters in the installers answers file that
relate to the puppetserver version. This is because we determine them in
params.pp which means init.pp has them. The result is that when a user
upgrades, their answers need to be reset. Katello has a hook to always
do this, Foreman has nothing.

By defaulting to undef and moving the the determination into server.pp
we can avoid this whole problem.
  • Loading branch information
ekohl authored and mmoll committed Jan 11, 2019
1 parent ac2fdb0 commit 899bb08
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 39 deletions.
8 changes: 4 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
#
# $server_puppetserver_dir:: The path of the puppetserver config dir
#
# $server_puppetserver_version:: The version of puppetserver 2 installed (or being installed)
# $server_puppetserver_version:: The version of puppetserver installed (or being installed)
# Unfortunately, different versions of puppetserver need
# configuring differently. The default is derived from the
# installed puppet version. Generally it's not needed to
Expand Down Expand Up @@ -617,7 +617,7 @@
Optional[Stdlib::Absolutepath] $server_puppetserver_vardir = $puppet::params::server_puppetserver_vardir,
Optional[Stdlib::Absolutepath] $server_puppetserver_rundir = $puppet::params::server_puppetserver_rundir,
Optional[Stdlib::Absolutepath] $server_puppetserver_logdir = $puppet::params::server_puppetserver_logdir,
Pattern[/^[\d]\.[\d]+\.[\d]+$/] $server_puppetserver_version = $puppet::params::server_puppetserver_version,
Optional[Pattern[/^[\d]\.[\d]+\.[\d]+$/]] $server_puppetserver_version = $puppet::params::server_puppetserver_version,
Variant[Undef, String[0], Stdlib::Absolutepath] $server_external_nodes = $puppet::params::server_external_nodes,
Array[String] $server_cipher_suites = $puppet::params::server_cipher_suites,
Optional[String] $server_config_version = $puppet::params::server_config_version,
Expand Down Expand Up @@ -671,7 +671,7 @@
String $server_jvm_config = $puppet::params::server_jvm_config,
Pattern[/^[0-9]+[kKmMgG]$/] $server_jvm_min_heap_size = $puppet::params::server_jvm_min_heap_size,
Pattern[/^[0-9]+[kKmMgG]$/] $server_jvm_max_heap_size = $puppet::params::server_jvm_max_heap_size,
Variant[String,Array[String]] $server_jvm_extra_args = $puppet::params::server_jvm_extra_args,
Optional[Variant[String,Array[String]]] $server_jvm_extra_args = $puppet::params::server_jvm_extra_args,
Optional[String] $server_jvm_cli_args = $puppet::params::server_jvm_cli_args,
Optional[Stdlib::Absolutepath] $server_jruby_gem_home = $puppet::params::server_jruby_gem_home,
Integer[1] $server_max_active_instances = $puppet::params::server_max_active_instances,
Expand All @@ -684,7 +684,7 @@
Boolean $server_allow_header_cert_info = $puppet::params::server_allow_header_cert_info,
Integer[0] $server_web_idle_timeout = $puppet::params::server_web_idle_timeout,
Boolean $server_puppetserver_jruby9k = $puppet::params::server_puppetserver_jruby9k,
Boolean $server_puppetserver_metrics = $puppet::params::server_puppetserver_metrics,
Optional[Boolean] $server_puppetserver_metrics = $puppet::params::server_puppetserver_metrics,
Boolean $server_metrics_jmx_enable = $::puppet::params::server_metrics_jmx_enable,
Boolean $server_metrics_graphite_enable = $::puppet::params::server_metrics_graphite_enable,
String $server_metrics_graphite_host = $::puppet::params::server_metrics_graphite_host,
Expand Down
31 changes: 6 additions & 25 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,9 @@
default => '/etc/default/puppetserver',
}

$server_jvm_java_bin = '/usr/bin/java'

if versioncmp($::puppetversion, '5.0.0') < 0 {
$server_jvm_extra_args = '-XX:MaxPermSize=256m'
} else {
$server_jvm_extra_args = '-Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger'
}

$server_jvm_cli_args = undef
$server_jvm_java_bin = '/usr/bin/java'
$server_jvm_extra_args = undef
$server_jvm_cli_args = undef

# This is some very trivial "tuning". See the puppet reference:
# https://docs.puppet.com/puppetserver/latest/tuning_guide.html
Expand Down Expand Up @@ -419,29 +413,16 @@
$server_ca_allow_auth_extensions = false
$server_ca_enable_infra_crl = false

$server_puppetserver_version = undef

# Puppetserver >= 2.2 Which auth.conf shall we use?
$server_use_legacy_auth_conf = false

# For Puppetserver, certain configuration parameters are version specific. We assume a particular version here.
if versioncmp($::puppetversion, '6.0.0') >= 0 {
$server_puppetserver_version = '6.0.0'
} elsif versioncmp($::puppetversion, '5.5.7') >= 0 {
$server_puppetserver_version = '5.3.6'
} elsif versioncmp($::puppetversion, '5.5.0') >= 0 {
$server_puppetserver_version = '5.3.0'
} elsif versioncmp($::puppetversion, '5.1.0') >= 0 {
$server_puppetserver_version = '5.1.0'
} elsif versioncmp($::puppetversion, '5.0.0') >= 0 {
$server_puppetserver_version = '5.0.0'
} else {
$server_puppetserver_version = '2.7.0'
}

# For Puppetserver 5, use JRuby 9k?
$server_puppetserver_jruby9k = false

# this switch also controls Ruby profiling, by default disabled for Puppetserver 2.x, enabled for 5.x
$server_puppetserver_metrics = versioncmp($::puppetversion, '5.0.0') >= 0
$server_puppetserver_metrics = undef

# Puppetserver metrics shipping
$server_metrics_jmx_enable = true
Expand Down
43 changes: 36 additions & 7 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@
#
# $puppetserver_dir:: The path of the puppetserver config dir
#
# $puppetserver_version:: The version of puppetserver 2 installed (or being installed)
# Unfortunately, different versions of puppetserver need configuring differently,
# and there's no easy way of determining which version is being installed.
# Defaults to '2.3.1' but can be overriden if you're installing an older version.
# $puppetserver_version:: The version of puppetserver installed (or being installed)
# Unfortunately, different versions of puppetserver need configuring differently.
# By default we attempt to derive the version from the puppet version itself but
# can be overriden if you're installing an older version.
#
# $max_active_instances:: Max number of active jruby instances. Defaults to
# processor count
Expand Down Expand Up @@ -356,7 +356,7 @@
Optional[Stdlib::Absolutepath] $puppetserver_rundir = $::puppet::server_puppetserver_rundir,
Optional[Stdlib::Absolutepath] $puppetserver_logdir = $::puppet::server_puppetserver_logdir,
Stdlib::Absolutepath $puppetserver_dir = $::puppet::server_puppetserver_dir,
Pattern[/^[\d]\.[\d]+\.[\d]+$/] $puppetserver_version = $::puppet::server_puppetserver_version,
Optional[Pattern[/^[\d]\.[\d]+\.[\d]+$/]] $puppetserver_version = $::puppet::server_puppetserver_version,
Variant[Undef, String[0], Stdlib::Absolutepath] $external_nodes = $::puppet::server_external_nodes,
Array[String] $cipher_suites = $::puppet::server_cipher_suites,
Optional[String] $config_version = $::puppet::server_config_version,
Expand Down Expand Up @@ -411,7 +411,7 @@
String $jvm_config = $::puppet::server_jvm_config,
Pattern[/^[0-9]+[kKmMgG]$/] $jvm_min_heap_size = $::puppet::server_jvm_min_heap_size,
Pattern[/^[0-9]+[kKmMgG]$/] $jvm_max_heap_size = $::puppet::server_jvm_max_heap_size,
Variant[String,Array[String]] $jvm_extra_args = $::puppet::server_jvm_extra_args,
Optional[Variant[String,Array[String]]] $jvm_extra_args = $::puppet::server_jvm_extra_args,
Optional[String] $jvm_cli_args = $::puppet::server_jvm_cli_args,
Optional[Stdlib::Absolutepath] $jruby_gem_home = $::puppet::server_jruby_gem_home,
Integer[1] $max_active_instances = $::puppet::server_max_active_instances,
Expand All @@ -423,7 +423,7 @@
Boolean $environment_class_cache_enabled = $::puppet::server_environment_class_cache_enabled,
Boolean $allow_header_cert_info = $::puppet::server_allow_header_cert_info,
Boolean $puppetserver_jruby9k = $::puppet::server_puppetserver_jruby9k,
Boolean $puppetserver_metrics = $::puppet::server_puppetserver_metrics,
Optional[Boolean] $puppetserver_metrics = $::puppet::server_puppetserver_metrics,
Boolean $metrics_jmx_enable = $::puppet::server_metrics_jmx_enable,
Boolean $metrics_graphite_enable = $::puppet::server_metrics_graphite_enable,
String $metrics_graphite_host = $::puppet::server_metrics_graphite_host,
Expand Down Expand Up @@ -468,6 +468,35 @@
$config_version_cmd = $config_version
}

# For Puppetserver, certain configuration parameters are version specific. We
# assume a particular version here.
if $puppetserver_version {
$real_puppetserver_version = $puppetserver_version
} elsif versioncmp($::puppetversion, '6.0.0') >= 0 {
$real_puppetserver_version = '6.0.0'
} elsif versioncmp($::puppetversion, '5.5.7') >= 0 {
$real_puppetserver_version = '5.3.6'
} elsif versioncmp($::puppetversion, '5.5.0') >= 0 {
$real_puppetserver_version = '5.3.0'
} elsif versioncmp($::puppetversion, '5.1.0') >= 0 {
$real_puppetserver_version = '5.1.0'
} elsif versioncmp($::puppetversion, '5.0.0') >= 0 {
$real_puppetserver_version = '5.0.0'
} else {
$real_puppetserver_version = '2.7.0'
}

# Prefer the user setting,otherwise disable for Puppetserver 2.x, enabled for 5.x
$real_puppetserver_metrics = pick($puppetserver_metrics, versioncmp($real_puppetserver_version, '5.0.0') >= 0)

if $jvm_extra_args {
$real_jvm_extra_args = $jvm_extra_args
} elsif versioncmp($real_puppetserver_version, '5.0.0') < 0 {
$real_jvm_extra_args = '-XX:MaxPermSize=256m'
} else {
$real_jvm_extra_args = '-Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger'
}

contain puppet::server::install
contain puppet::server::config
contain puppet::server::service
Expand Down
6 changes: 3 additions & 3 deletions manifests/server/puppetserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
class puppet::server::puppetserver (
$config = $::puppet::server::jvm_config,
$java_bin = $::puppet::server::jvm_java_bin,
$jvm_extra_args = $::puppet::server::jvm_extra_args,
$jvm_extra_args = $::puppet::server::real_jvm_extra_args,
$jvm_cli_args = $::puppet::server::jvm_cli_args,
$jvm_min_heap_size = $::puppet::server::jvm_min_heap_size,
$jvm_max_heap_size = $::puppet::server::jvm_max_heap_size,
Expand Down Expand Up @@ -101,12 +101,12 @@
$server_ca_auth_required = $::puppet::server::ca_auth_required,
$server_ca_client_whitelist = $::puppet::server::ca_client_whitelist,
$server_admin_api_whitelist = $::puppet::server::admin_api_whitelist,
$server_puppetserver_version = $::puppet::server::puppetserver_version,
$server_puppetserver_version = $::puppet::server::real_puppetserver_version,
$server_use_legacy_auth_conf = $::puppet::server::use_legacy_auth_conf,
$server_check_for_updates = $::puppet::server::check_for_updates,
$server_environment_class_cache_enabled = $::puppet::server::environment_class_cache_enabled,
$server_jruby9k = $::puppet::server::puppetserver_jruby9k,
$server_metrics = $::puppet::server::puppetserver_metrics,
$server_metrics = $::puppet::server::real_puppetserver_metrics,
$metrics_jmx_enable = $::puppet::server::metrics_jmx_enable,
$metrics_graphite_enable = $::puppet::server::metrics_graphite_enable,
$metrics_graphite_host = $::puppet::server::metrics_graphite_host,
Expand Down

0 comments on commit 899bb08

Please sign in to comment.