Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded default memory configuration #194

Merged
merged 2 commits into from
Jul 26, 2021
Merged
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
38 changes: 7 additions & 31 deletions functions/generate_pe_conf.pp
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
# Generates a pe.conf file, removing undef parameters
# @summary Generate a pe.conf file in JSON format
#
# @param user_settings
# @param settings
# A hash of settings to set in the config file. Any keys that are set to
# undef will not be included in the config file. This is done to reduce the
# amount of logic required within plans if parameters are not passed in.
# undef will not be included in the config file.
#
function peadm::generate_pe_conf (
Hash $settings,
) {
) >> String {
# Check that console_admin_password is present
unless $settings['console_admin_password'] =~ String {
fail('pe.conf must have the console_admin_password set')
}

# Define the configuration settings that will be placed in pe.conf by
# default. These can be overriden by user-supplied values in the $settings
# hash.
$defaults = {
'puppet_enterprise::profile::master::java_args' => {
'Xmx' => '2048m',
'Xms' => '512m',
},
'puppet_enterprise::profile::console::java_args' => {
'Xmx' => '768m',
'Xms' => '256m',
},
'puppet_enterprise::profile::orchestrator::java_args' => {
'Xmx' => '768m',
'Xms' => '256m',
},
'puppet_enterprise::profile::puppetdb::java_args' => {
'Xmx' => '768m',
'Xms' => '256m',
},
}

# Merge the defaults with user-supplied settings, remove anything that is
# undef, then output to JSON (and therefore HOCON, because HOCON is a
# superset of JSON)
($defaults + $settings).filter |$key,$value| {
# Remove anything that is undef, then output to JSON (and therefore HOCON,
# because HOCON is a superset of JSON)
$settings.filter |$key,$value| {
$value != undef
}.to_json_pretty()
}