Skip to content

Commit 832f318

Browse files
committed
Switch last templates to EPP
A lot of work was done to convert the module templates form ERB to EPP, but a few templates where still to be converted. Along with various benefits, EPP templates offer better detection for access to undefined variables. This refactoring therefore fix a few issues that where reported while converting. Also a bunch of outdated comments about which template use which variable where removed no that this usage is explicit. The extensive test suite helped ensure the conversion was not introducing regressions.
1 parent 675fb82 commit 832f318

39 files changed

+1051
-2398
lines changed

Diff for: manifests/mod/php.pp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Optional[String] $path = undef,
3333
Array $extensions = ['.php'],
3434
Optional[String] $content = undef,
35-
String $template = 'apache/mod/php.conf.erb',
35+
String $template = 'apache/mod/php.conf.epp',
3636
Optional[String] $source = undef,
3737
Optional[String] $root_group = $apache::params::root_group,
3838
Optional[String] $php_version = $apache::params::php_version,
@@ -63,9 +63,9 @@
6363
fail('apache::mod::php requires apache::mod::prefork or apache::mod::itk; please enable mpm_module => \'prefork\' or mpm_module => \'itk\' on Class[\'apache\']')
6464
}
6565

66-
if $source and ($content or $template != 'apache/mod/php.conf.erb') {
66+
if $source and ($content or $template != 'apache/mod/php.conf.epp') {
6767
warning('source and content or template parameters are provided. source parameter will be used')
68-
} elsif $content and $template != 'apache/mod/php.conf.erb' {
68+
} elsif $content and $template != 'apache/mod/php.conf.epp' {
6969
warning('content and template parameters are provided. content parameter will be used')
7070
}
7171

Diff for: manifests/mod/security.pp

+19-38
Original file line numberDiff line numberDiff line change
@@ -316,49 +316,30 @@
316316
}
317317

318318
if $manage_security_crs {
319-
# Template uses:
320-
# - $_secdefaultaction
321-
# - $critical_anomaly_score
322-
# - $error_anomaly_score
323-
# - $warning_anomaly_score
324-
# - $notice_anomaly_score
325-
# - $inbound_anomaly_threshold
326-
# - $outbound_anomaly_threshold
327-
# - $paranoia_level
328-
# - $executing_paranoia_level
329-
# - $allowed_methods
330-
# - $content_types
331-
# - $restricted_extensions
332-
# - $restricted_headers
333-
# - $secrequestmaxnumargs
334-
# - $enable_dos_protection
335-
# - $dos_burst_time_slice
336-
# - $dos_counter_threshold
337-
# - $dos_block_timeout
338319
$security_crs_parameters = {
339-
'_secdefaultaction' => $_secdefaultaction,
340-
'critical_anomaly_score' => $critical_anomaly_score,
341-
'error_anomaly_score' => $error_anomaly_score,
342-
'warning_anomaly_score' => $warning_anomaly_score,
343-
'notice_anomaly_score' => $notice_anomaly_score,
344-
'inbound_anomaly_threshold' => $inbound_anomaly_threshold,
345-
'outbound_anomaly_threshold' => $outbound_anomaly_threshold,
346-
'secrequestmaxnumargs' => $secrequestmaxnumargs,
347-
'allowed_methods' => $allowed_methods,
348-
'content_types' => $content_types,
349-
'restricted_extensions' => $restricted_extensions,
350-
'restricted_headers' => $restricted_headers,
351-
'paranoia_level' => $paranoia_level,
352-
'executing_paranoia_level' => $executing_paranoia_level,
353-
'enable_dos_protection' => $enable_dos_protection,
354-
'dos_burst_time_slice' => $dos_burst_time_slice,
355-
'dos_counter_threshold' => $dos_counter_threshold,
356-
'dos_block_timeout' => $dos_block_timeout,
320+
'_secdefaultaction' => $_secdefaultaction,
321+
'critical_anomaly_score' => $critical_anomaly_score,
322+
'error_anomaly_score' => $error_anomaly_score,
323+
'warning_anomaly_score' => $warning_anomaly_score,
324+
'notice_anomaly_score' => $notice_anomaly_score,
325+
'inbound_anomaly_threshold' => $inbound_anomaly_threshold,
326+
'outbound_anomaly_threshold' => $outbound_anomaly_threshold,
327+
'secrequestmaxnumargs' => $secrequestmaxnumargs,
328+
'allowed_methods' => $allowed_methods,
329+
'content_types' => $content_types,
330+
'restricted_extensions' => $restricted_extensions,
331+
'restricted_headers' => $restricted_headers,
332+
'paranoia_level' => $paranoia_level,
333+
'executing_paranoia_level' => $executing_paranoia_level,
334+
'enable_dos_protection' => $enable_dos_protection,
335+
'dos_burst_time_slice' => $dos_burst_time_slice,
336+
'dos_counter_threshold' => $dos_counter_threshold,
337+
'dos_block_timeout' => $dos_block_timeout,
357338
}
358339

359340
file { "${modsec_dir}/security_crs.conf":
360341
ensure => file,
361-
content => template('apache/mod/security_crs.conf.erb'),
342+
content => epp('apache/mod/security_crs.conf.epp', $security_crs_parameters),
362343
require => File[$modsec_dir],
363344
notify => Class['apache::service'],
364345
}

Diff for: manifests/mod/status.pp

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@
4040
$requires_defaults = 'ip 127.0.0.1 ::1'
4141

4242
# Template uses $extended_status, $status_path
43+
$status_params = {
44+
'extended_status' => $extended_status,
45+
'status_path' => $status_path,
46+
'requires' => $requires,
47+
'requires_defaults' => $requires_defaults,
48+
}
4349
file { 'status.conf':
4450
ensure => file,
4551
path => "${apache::mod_dir}/status.conf",
4652
mode => $apache::file_mode,
47-
content => template('apache/mod/status.conf.erb'),
53+
content => epp('apache/mod/status.conf.epp', $status_params),
4854
require => Exec["mkdir ${apache::mod_dir}"],
4955
before => File[$apache::mod_dir],
5056
notify => Class['apache::service'],

0 commit comments

Comments
 (0)