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

Convert ERB templates to EPP #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Fri Jan 03 2025 Steven Pritchard <[email protected]> - 8.10.1
- Convert templates from ERB to EPP (#159)

* Thu Jan 02 2025 Steven Pritchard <[email protected]> - 8.10.0
- Clean up for rubocop
- Fix more use of legacy facts
Expand Down
20 changes: 10 additions & 10 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,16 @@
Rsyslog::QueueType $main_msg_queue_type = 'LinkedList',
String[1] $main_msg_queue_filename = 'main_msg_queue',
Integer[0] $main_msg_queue_max_file_size = 5,
Optional[Integer[0]] $main_msg_queue_size = undef,
Optional[Integer[0]] $main_msg_queue_high_watermark = undef,
Optional[Integer[0]] $main_msg_queue_low_watermark = undef,
Optional[Integer[0]] $main_msg_queue_discardmark = undef,
Optional[Integer[0]] $main_msg_queue_worker_thread_minimum_messages = undef,
Optional[Integer[0]] $main_msg_queue_worker_threads = undef,
Integer[0] $main_msg_queue_size = [Integer(([$facts['memory']['system']['total_bytes'] >> 20, 128].max() * 2048) / 100), 2097152].min(),
Integer[0] $main_msg_queue_high_watermark = round($main_msg_queue_size * 0.9),
Integer[0] $main_msg_queue_low_watermark = round($main_msg_queue_size * 0.7),
Integer[0] $main_msg_queue_discardmark = round($main_msg_queue_size * 0.98),
Integer[0] $main_msg_queue_worker_thread_minimum_messages = Integer($main_msg_queue_size / (([$facts['processors']['count'], 2].max() - 1) * 4)),
Integer[0] $main_msg_queue_worker_threads = [$facts['processors']['count'] - 1, 1].max(),
Integer[0] $main_msg_queue_timeout_enqueue = 100,
Integer[0] $main_msg_queue_dequeue_slowdown = 0,
Rsyslog::Boolean $main_msg_queue_save_on_shutdown = true,
Optional[Integer[0]] $main_msg_queue_max_disk_space = undef,
Variant[Integer[0], String[1]] $main_msg_queue_max_disk_space = "${round($main_msg_queue_size / 1024)}M",

Rsyslog::Boolean $repeated_msg_reduction = true,
Stdlib::Absolutepath $work_directory = '/var/spool/rsyslog',
Expand Down Expand Up @@ -424,7 +424,7 @@
Optional[Rsyslog::Options] $extra_imtcp_mod_params = undef,
Optional[Rsyslog::Options] $extra_imudp_mod_params = undef,
Optional[Rsyslog::Options] $extra_imuxsock_mod_params = undef,
Optional[Rsyslog::Options] $extra_main_queue_params = undef
Optional[Rsyslog::Options] $extra_main_queue_params = undef,
) {
assert_private()

Expand Down Expand Up @@ -536,7 +536,7 @@
| RSYSLOG_CONF

file { '/etc/rsyslog.conf':
ensure => 'present',
ensure => file,
owner => 'root',
group => 'root',
mode => '0600',
Expand All @@ -557,7 +557,7 @@
}

rsyslog::rule { '00_simp_pre_logging/global.conf':
content => template("${module_name}/config/pre_logging.conf.erb")
content => epp("${module_name}/config/pre_logging.conf.epp"),
}

rsyslog::rule { '09_failover_hack/failover_hack.conf':
Expand Down
8 changes: 4 additions & 4 deletions manifests/rule/console.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#
define rsyslog::rule::console (
String $rule,
Array[String] $users
Array[String] $users,
) {
$_safe_name = regsubst($name,'/','__')
$_safe_name = regsubst($name, '/', '__')

rsyslog::rule { "06_simp_console/${_safe_name}.conf":
content => inline_template('if (<%= @rule.split("\n").collect{ |x| x.sub(/^\s+/,"") }.join("\n") %>) then action( type="omusrmsg"
<%= @users.sort.map{|x| user = %(Users="#{x}")}.join("\n ") %>
content => inline_epp('if (<%= $rule.split("\n").map |$x| { $x.lstrip() }.join("\n") %>) then action( type="omusrmsg"
<%= $users.sort.map |$x| { "Users=\"${x}\"" }.join("\n ") %>
)'
)
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/rule/data_source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
#
# The filename that you will be dropping into place.
#
define rsyslog::rule::data_source(
String $rule
define rsyslog::rule::data_source (
String $rule,
) {
$_safe_name = regsubst($name,'/','__')
$_safe_name = regsubst($name, '/', '__')

rsyslog::rule { "05_simp_data_sources/${_safe_name}.conf":
content => inline_template('<%= @rule.split("\n").collect{ |x| x.sub(/^\s+/,"") }.join("\n") %>')
content => inline_epp('<%= $rule.split("\n").map |$x| { $x.lstrip() }.join("\n") %>'),
}
}
2 changes: 1 addition & 1 deletion manifests/rule/drop.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
$_safe_name = regsubst($name,'/','__')

rsyslog::rule { "07_simp_drop_rules/${_safe_name}.conf":
content => inline_template('if (<%= @rule.split("\n").collect{ |x| x.sub(/^\s+/,"") }.join("\n") + ") then stop\n" %>')
content => inline_epp('if (<%= $rule.split("\n").map |$x| { $x.lstrip() }.join("\n") %>) then stop\n" %>')
}
}
63 changes: 58 additions & 5 deletions manifests/rule/local.pp
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,14 @@
Optional[Integer[0]] $queue_dequeue_slowdown = undef,
Optional[Integer[0]] $queue_dequeue_time_begin = undef,
Optional[Integer[0]] $queue_dequeue_time_end = undef,
Optional[String[1]] $content = undef
Optional[String[1]] $content = undef,
) {

unless ($rule or $content) {
fail('You must specify "$rule" if you are not specifying "$content"')
}

$_safe_name = regsubst($name,'/','__')


if $content {
$_content = $content
}
Expand Down Expand Up @@ -235,10 +233,65 @@
}
}

$_content = template("${module_name}/rule/local.erb")
$_content = epp(
"${module_name}/rule/local.epp",
'rule' => $rule,
'target_log_file' => $target_log_file,
'stop_processing' => $stop_processing,
'dyna_file' => $dyna_file,
'template' => $template,
'dyna_file_cache_size' => $dyna_file_cache_size,
'zip_level' => $zip_level,
'very_robust_zip' => $very_robust_zip,
'flush_interval' => $flush_interval,
'async_writing' => $async_writing,
'flush_on_tx_end' => $flush_on_tx_end,
'io_buffer_size' => $io_buffer_size,
'dir_owner' => $dir_owner,
'dir_owner_num' => $dir_owner_num,
'dir_group' => $dir_group,
'dir_group_num' => $dir_group_num,
'file_owner' => $file_owner,
'file_owner_num' => $file_owner_num,
'file_group' => $file_group,
'file_group_num' => $file_group_num,
'file_create_mode' => $file_create_mode,
'dir_create_mode' => $dir_create_mode,
'fail_on_chown_failure' => $fail_on_chown_failure,
'create_dirs' => $create_dirs,
'sync' => $sync,
'sig_provider' => $sig_provider,
'cry_provider' => $cry_provider,
'queue_filename' => $queue_filename,
'queue_spool_directory' => $queue_spool_directory,
'queue_size' => $queue_size,
'queue_dequeue_batch_size' => $queue_dequeue_batch_size,
'queue_max_disk_space' => $queue_max_disk_space,
'queue_high_watermark' => $queue_high_watermark,
'queue_low_watermark' => $queue_low_watermark,
'queue_full_delay_mark' => $queue_full_delay_mark,
'queue_light_delay_mark' => $queue_light_delay_mark,
'queue_discard_mark' => $queue_discard_mark,
'queue_discard_severity' => $queue_discard_severity,
'queue_checkpoint_interval' => $queue_checkpoint_interval,
'queue_sync_queue_files' => $queue_sync_queue_files,
'queue_type' => $queue_type,
'queue_worker_threads' => $queue_worker_threads,
'queue_timeout_shutdown' => $queue_timeout_shutdown,
'queue_timeout_action_completion' => $queue_timeout_action_completion,
'queue_timeout_enqueue' => $queue_timeout_enqueue,
'queue_timeout_worker_thread_shutdown' => $queue_timeout_worker_thread_shutdown,
'queue_worker_thread_minimum_messages' => $queue_worker_thread_minimum_messages,
'queue_max_file_size' => $queue_max_file_size,
'queue_save_on_shutdown' => $queue_save_on_shutdown,
'queue_dequeue_slowdown' => $queue_dequeue_slowdown,
'queue_dequeue_time_begin' => $queue_dequeue_time_begin,
'queue_dequeue_time_end' => $queue_dequeue_time_end,
'safe_name' => $_safe_name,
)
}

rsyslog::rule { "99_simp_local/${_safe_name}.conf":
content => $_content
content => $_content,
}
}
6 changes: 3 additions & 3 deletions manifests/rule/other.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#fine: rsyslog::rule::other
#
define rsyslog::rule::other (
String $rule
String $rule,
) {
$_safe_name = regsubst($name,'/','__')
$_safe_name = regsubst($name, '/', '__')

rsyslog::rule { "20_simp_other/${_safe_name}.conf":
content => inline_template('<%= @rule.split("\n").collect{ |x| x.sub(/^\s+/,"") }.join("\n") %>')
content => inline_epp('<%= $rule.split("\n").map |$x| { $x.lstrip() }.join("\n") %>'),
}
}
65 changes: 60 additions & 5 deletions manifests/rule/remote.pp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
Optional[Integer[0]] $queue_dequeue_slowdown = undef,
Optional[Integer[0]] $queue_dequeue_time_begin = undef,
Optional[Integer[0]] $queue_dequeue_time_end = undef,
Optional[String[1]] $content = undef
Optional[String[1]] $content = undef,
) {
include 'rsyslog'

Expand Down Expand Up @@ -275,7 +275,7 @@
}
else {
$_queue_spool_directory = $rsyslog::queue_spool_directory
}
} # FIXME: This appears to be unused

$_use_tls = ( $rsyslog::enable_tls_logging and $dest_type != 'udp' )

Expand All @@ -287,7 +287,7 @@
}

if $_use_tls {
if $stream_driver_permitted_peers {
if $stream_driver_permitted_peers {
$_stream_driver_permitted_peers = $stream_driver_permitted_peers
} else {
# If $stream_driver_permitted_peers is not defined, then determine if
Expand All @@ -311,6 +311,8 @@
}
}
}
} else {
$_stream_driver_permitted_peers = undef
}

# Basic validation for the action queue parameters
Expand Down Expand Up @@ -349,10 +351,63 @@
}
}

$_content = template("${module_name}/rule/remote.erb")
$_content = epp(
"${module_name}/rule/remote.epp",
'rule' => $rule,
'stop_processing' => $stop_processing,
'template' => $template,
'dest' => $_dest,
'dest_type' => $dest_type,
'failover_log_servers' => $_failover_servers,
'tcp_framing' => $tcp_framing,
'zip_level' => $zip_level,
'max_error_messages' => $max_error_messages,
'compression_mode' => $compression_mode,
'compression_stream_flush_on_tx_end' => $compression_stream_flush_on_tx_end,
'rebind_interval' => $rebind_interval,
'keep_alive' => $keep_alive,
'keep_alive_probes' => $keep_alive_probes,
'keep_alive_interval' => $keep_alive_interval,
'keep_alive_time' => $keep_alive_time,
'action_resume_interval' => $action_resume_interval,
'action_resume_retry_count' => $action_resume_retry_count,
'stream_driver' => $stream_driver,
'stream_driver_mode' => $stream_driver_mode,
'stream_driver_auth_mode' => $stream_driver_auth_mode,
'stream_driver_permitted_peers' => $_stream_driver_permitted_peers,
'resend_last_msg_on_reconnect' => $resend_last_msg_on_reconnect,
'udp_send_to_all' => $udp_send_to_all,
'queue_filename' => $_queue_filename,
'queue_spool_directory' => $_queue_spool_directory,
'queue_size' => $queue_size,
'queue_dequeue_batch_size' => $queue_dequeue_batch_size,
'queue_max_disk_space' => $queue_max_disk_space,
'queue_high_watermark' => $queue_high_watermark,
'queue_low_watermark' => $queue_low_watermark,
'queue_full_delay_mark' => $queue_full_delay_mark,
'queue_light_delay_mark' => $queue_light_delay_mark,
'queue_discard_mark' => $queue_discard_mark,
'queue_discard_severity' => $queue_discard_severity,
'queue_checkpoint_interval' => $queue_checkpoint_interval,
'queue_sync_queue_files' => $queue_sync_queue_files,
'queue_type' => $queue_type,
'queue_worker_threads' => $queue_worker_threads,
'queue_timeout_shutdown' => $queue_timeout_shutdown,
'queue_timeout_action_completion' => $queue_timeout_action_completion,
'queue_timeout_enqueue' => $queue_timeout_enqueue,
'queue_timeout_worker_thread_shutdown' => $queue_timeout_worker_thread_shutdown,
'queue_worker_thread_minimum_messages' => $queue_worker_thread_minimum_messages,
'queue_max_file_size' => $queue_max_file_size,
'queue_save_on_shutdown' => $queue_save_on_shutdown,
'queue_dequeue_slowdown' => $queue_dequeue_slowdown,
'queue_dequeue_time_begin' => $queue_dequeue_time_begin,
'queue_dequeue_time_end' => $queue_dequeue_time_end,
'safe_name' => $_safe_name,
'use_tls' => $_use_tls,
)
}

rsyslog::rule { "10_simp_remote/${_safe_name}.conf":
content => $_content
content => $_content,
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-rsyslog",
"version": "8.10.0",
"version": "8.10.1",
"author": "SIMP Team",
"summary": "A puppet module to support RSyslog version 8.",
"license": "Apache-2.0",
Expand Down
Loading
Loading