(PDB-1430) overwritable java_args

this creates a new config setting, merge_default_java_args, that users may set
to false to override the default java_args.
This commit is contained in:
Wyatt Alt 2015-09-21 14:23:12 -07:00
parent e371db7957
commit 4a1f3245d0
6 changed files with 65 additions and 15 deletions

View file

@ -377,6 +377,13 @@ Java VM options used for overriding default Java VM options specified in PuppetD
Example: to set `-Xmx512m -Xms256m` options use `{ '-Xmx' => '512m', '-Xms' => '256m' }`
####`merge_default_java_args`
Sets whether the provided java args should be merged with the defaults, or
should override the defaults. This setting is necessary if any of the defaults
are to be removed. Defaults to true. If false, the `java_args` in the puppetdb
init config file will reflect only what is passed via the `java_args` param.
####`max_threads`
Jetty option to explicitly set max-thread. The default is undef, so the PuppetDB-jetty default is used.

View file

@ -0,0 +1,8 @@
module Puppet::Parser::Functions
newfunction(:puppetdb_flatten_java_args, :type => :rvalue) do |args|
java_args = args[0] || {}
args = ""
java_args.each {|k,v| args += "#{k}#{v} "}
"\"#{args.chomp(' ')}\""
end
end

View file

@ -61,6 +61,7 @@ class puppetdb (
$confdir = $puppetdb::params::confdir,
$manage_firewall = $puppetdb::params::manage_firewall,
$java_args = $puppetdb::params::java_args,
$merge_default_java_args = $puppetdb::params::merge_default_java_args,
$max_threads = $puppetdb::params::max_threads,
$command_threads = $puppetdb::params::command_threads,
$store_usage = $puppetdb::params::store_usage,
@ -108,6 +109,7 @@ class puppetdb (
puppetdb_service_status => $puppetdb_service_status,
confdir => $confdir,
java_args => $java_args,
merge_default_java_args => $merge_default_java_args,
max_threads => $max_threads,
read_database => $read_database,
read_database_host => $read_database_host,

View file

@ -57,8 +57,9 @@ class puppetdb::params inherits puppetdb::globals {
$read_conn_keep_alive = '45'
$read_conn_lifetime = '0'
$manage_firewall = true
$java_args = {}
$manage_firewall = true
$java_args = {}
$merge_default_java_args = true
$puppetdb_package = 'puppetdb'
$puppetdb_service = 'puppetdb'

View file

@ -56,6 +56,7 @@ class puppetdb::server (
$confdir = $puppetdb::params::confdir,
$manage_firewall = $puppetdb::params::manage_firewall,
$java_args = $puppetdb::params::java_args,
$merge_default_java_args = $puppetdb::params::merge_default_java_args,
$max_threads = $puppetdb::params::max_threads,
$command_threads = $puppetdb::params::command_threads,
$store_usage = $puppetdb::params::store_usage,
@ -235,19 +236,30 @@ class puppetdb::server (
}
if !empty($java_args) {
create_resources(
'ini_subsetting',
puppetdb_create_subsetting_resource_hash(
$java_args,
{ ensure => present,
section => '',
key_val_separator => '=',
path => $puppetdb::params::puppetdb_initconf,
setting => 'JAVA_ARGS',
require => Package[$puppetdb_package],
notify => Service[$puppetdb_service],
})
)
if $merge_default_java_args {
create_resources(
'ini_subsetting',
puppetdb_create_subsetting_resource_hash(
$java_args,
{ensure => present,
section => '',
key_val_separator => '=',
path => $puppetdb::params::puppetdb_initconf,
setting => 'JAVA_ARGS',
require => Package[$puppetdb_package],
notify => Service[$puppetdb_service],
}))
} else {
ini_setting {'java_args':
ensure => present,
section => '',
path => $puppetdb::params::puppetdb_initconf,
setting => 'JAVA_ARGS',
require => Package[$puppetdb_package],
notify => Service[$puppetdb_service],
value => puppetdb_flatten_java_args($java_args),
}
}
}
service { $puppetdb_service:

View file

@ -44,5 +44,25 @@ describe 'puppetdb::server', :type => :class do
end
end
describe 'when specifying JAVA_ARGS with merge_default_java_args false' do
let (:params) do
{
'java_args' => {'-Xms' => '2g'},
'merge_default_java_args' => false,
}
end
context 'on standard PuppetDB' do
it { should contain_ini_setting('java_args').
with(
'ensure' => 'present',
'path' => '/etc/sysconfig/puppetdb',
'section' => '',
'setting' => 'JAVA_ARGS',
'value' => '"-Xms2g"'
)}
end
end
end
end