Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions lib/puppet/parser/functions/puppetdb_flatten_java_args.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
$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,
Expand Down Expand Up @@ -108,6 +109,7 @@
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,
Expand Down
5 changes: 3 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
$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'
Expand Down
38 changes: 25 additions & 13 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
$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,
Expand Down Expand Up @@ -235,19 +236,30 @@
}

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:
Expand Down
20 changes: 20 additions & 0 deletions spec/unit/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,25 @@
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