|
1 |
| -# Generates a pe.conf file, removing undef parameters |
| 1 | +# @summary Generate a pe.conf file in JSON format |
2 | 2 | #
|
3 |
| -# @param user_settings |
| 3 | +# @param settings |
4 | 4 | # A hash of settings to set in the config file. Any keys that are set to
|
5 |
| -# undef will not be included in the config file. This is done to reduce the |
6 |
| -# amount of logic required within plans if parameters are not passed in. |
| 5 | +# undef will not be included in the config file. |
7 | 6 | #
|
8 | 7 | function peadm::generate_pe_conf (
|
9 | 8 | Hash $settings,
|
10 |
| -) { |
| 9 | +) >> String { |
11 | 10 | # Check that console_admin_password is present
|
12 | 11 | unless $settings['console_admin_password'] =~ String {
|
13 | 12 | fail('pe.conf must have the console_admin_password set')
|
14 | 13 | }
|
15 | 14 |
|
16 |
| - # Define the configuration settings that will be placed in pe.conf by |
17 |
| - # default. These can be overriden by user-supplied values in the $settings |
18 |
| - # hash. |
19 |
| - $defaults = { |
20 |
| - 'puppet_enterprise::profile::master::java_args' => { |
21 |
| - 'Xmx' => '2048m', |
22 |
| - 'Xms' => '512m', |
23 |
| - }, |
24 |
| - 'puppet_enterprise::profile::console::java_args' => { |
25 |
| - 'Xmx' => '768m', |
26 |
| - 'Xms' => '256m', |
27 |
| - }, |
28 |
| - 'puppet_enterprise::profile::orchestrator::java_args' => { |
29 |
| - 'Xmx' => '768m', |
30 |
| - 'Xms' => '256m', |
31 |
| - }, |
32 |
| - 'puppet_enterprise::profile::puppetdb::java_args' => { |
33 |
| - 'Xmx' => '768m', |
34 |
| - 'Xms' => '256m', |
35 |
| - }, |
36 |
| - } |
37 |
| - |
38 |
| - # Merge the defaults with user-supplied settings, remove anything that is |
39 |
| - # undef, then output to JSON (and therefore HOCON, because HOCON is a |
40 |
| - # superset of JSON) |
41 |
| - ($defaults + $settings).filter |$key,$value| { |
| 15 | + # Remove anything that is undef, then output to JSON (and therefore HOCON, |
| 16 | + # because HOCON is a superset of JSON) |
| 17 | + $settings.filter |$key,$value| { |
42 | 18 | $value != undef
|
43 | 19 | }.to_json_pretty()
|
44 | 20 | }
|
0 commit comments