From be8044d8f011eb40b2e367200eb28ec2a6c65d88 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 14:00:32 +0100 Subject: [PATCH 1/9] Added rsyslog_default_use_caller_module to enable pulling templates from the calling module --- manifests/init.pp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9c593c0..ca5a613 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -41,6 +41,9 @@ # @param rsyslog_default_file # `rsyslog_d` file template to use # +# @param rsyslog_default_use_caller_module +# `rsyslog_d` use the called module for templates +# # @param run_user # Which user rsyslog should run as # @@ -150,6 +153,7 @@ String[1] $rsyslog_conf_template_file = "${module_name}/rsyslog.conf.erb", Stdlib::Absolutepath $rsyslog_default = $rsyslog::params::rsyslog_default, String[1] $rsyslog_default_file = $rsyslog::params::default_config_file, + Boolean $rsyslog_default_use_caller_module = false, String[1] $run_user = $rsyslog::params::run_user, String[1] $run_group = $rsyslog::params::run_group, String[1] $log_user = $rsyslog::params::log_user, @@ -208,13 +212,24 @@ require => File[$rsyslog_d], } - file { $rsyslog_default: - ensure => file, - owner => 'root', - group => $run_group, - content => template("${module_name}/${rsyslog_default_file}.erb"), - notify => Service[$service_name], - require => File[$rsyslog_conf], + if($rsyslog_default_use_caller_module == true ) { + file { $rsyslog_default: + ensure => file, + owner => 'root', + group => $run_group, + content => template("${caller_module_name}/${rsyslog_default_file}.erb"), + notify => Service[$service_name], + require => File[$rsyslog_conf], + } + } else { + file { $rsyslog_default: + ensure => file, + owner => 'root', + group => $run_group, + content => template("${module_name}/${rsyslog_default_file}.erb"), + notify => Service[$service_name], + require => File[$rsyslog_conf], + } } file { $spool_dir: From 42b108903ee28adbd549ba1c116c4d984ed28a26 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 14:29:31 +0100 Subject: [PATCH 2/9] Debug --- manifests/init.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index ca5a613..9fe5288 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -213,6 +213,7 @@ } if($rsyslog_default_use_caller_module == true ) { + Notify("Caller module ${caller_module_name}") file { $rsyslog_default: ensure => file, owner => 'root', @@ -222,6 +223,7 @@ require => File[$rsyslog_conf], } } else { + Notify("Caller module ${caller_module_name}") file { $rsyslog_default: ensure => file, owner => 'root', From 6a6ad084d9cb3a7444044c78a25fca24feb062da Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 14:30:28 +0100 Subject: [PATCH 3/9] Tweak --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9fe5288..b6751b4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -223,7 +223,7 @@ require => File[$rsyslog_conf], } } else { - Notify("Caller module ${caller_module_name}") + Notify("Caller module ${module_name}") file { $rsyslog_default: ensure => file, owner => 'root', From fad0a4026fc0383e9d0e3175712e8b209e9cf8db Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 14:51:48 +0100 Subject: [PATCH 4/9] Cake --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b6751b4..4ee5e17 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -213,7 +213,7 @@ } if($rsyslog_default_use_caller_module == true ) { - Notify("Caller module ${caller_module_name}") + Notify("Caller module ${caller_module_name} - cake") file { $rsyslog_default: ensure => file, owner => 'root', @@ -223,7 +223,7 @@ require => File[$rsyslog_conf], } } else { - Notify("Caller module ${module_name}") + Notify("Caller module ${module_name} - Not cake") file { $rsyslog_default: ensure => file, owner => 'root', From 005d1bd39e6f6d2708d2f68a206d374b6ea34c79 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 14:53:05 +0100 Subject: [PATCH 5/9] Dumbass --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4ee5e17..f3b2864 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -213,7 +213,7 @@ } if($rsyslog_default_use_caller_module == true ) { - Notify("Caller module ${caller_module_name} - cake") + Notify{"Caller module ${caller_module_name} - cake": } file { $rsyslog_default: ensure => file, owner => 'root', @@ -223,7 +223,7 @@ require => File[$rsyslog_conf], } } else { - Notify("Caller module ${module_name} - Not cake") + Notify{"Caller module ${module_name}": } file { $rsyslog_default: ensure => file, owner => 'root', From e6cbb10de06356ca6cecba5e8d3c858b95184902 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 15:29:27 +0100 Subject: [PATCH 6/9] Cake --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index f3b2864..4a271d0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -212,13 +212,13 @@ require => File[$rsyslog_d], } - if($rsyslog_default_use_caller_module == true ) { + if($rsyslog_default_use_caller_module == false ) { Notify{"Caller module ${caller_module_name} - cake": } file { $rsyslog_default: ensure => file, owner => 'root', group => $run_group, - content => template("${caller_module_name}/${rsyslog_default_file}.erb"), + content => template("${rsyslog_default_file}.erb"), notify => Service[$service_name], require => File[$rsyslog_conf], } From 546e82498e8831394457cc16c44db2fb5c2c93f9 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 15:53:07 +0100 Subject: [PATCH 7/9] Clean up --- manifests/init.pp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4a271d0..80450de 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -41,8 +41,8 @@ # @param rsyslog_default_file # `rsyslog_d` file template to use # -# @param rsyslog_default_use_caller_module -# `rsyslog_d` use the called module for templates +# @param rsyslog_default_file_absolute_path +# `rsyslog_d` use the absolute template path # # @param run_user # Which user rsyslog should run as @@ -153,7 +153,7 @@ String[1] $rsyslog_conf_template_file = "${module_name}/rsyslog.conf.erb", Stdlib::Absolutepath $rsyslog_default = $rsyslog::params::rsyslog_default, String[1] $rsyslog_default_file = $rsyslog::params::default_config_file, - Boolean $rsyslog_default_use_caller_module = false, + Boolean $rsyslog_default_file_absolute_path = false, String[1] $run_user = $rsyslog::params::run_user, String[1] $run_group = $rsyslog::params::run_group, String[1] $log_user = $rsyslog::params::log_user, @@ -212,8 +212,7 @@ require => File[$rsyslog_d], } - if($rsyslog_default_use_caller_module == false ) { - Notify{"Caller module ${caller_module_name} - cake": } + if($rsyslog_default_file_absolute_path == false ) { file { $rsyslog_default: ensure => file, owner => 'root', @@ -223,7 +222,6 @@ require => File[$rsyslog_conf], } } else { - Notify{"Caller module ${module_name}": } file { $rsyslog_default: ensure => file, owner => 'root', From 0af510d640f31d96f070d32d4c8b0cdab336420e Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Tue, 20 May 2025 15:54:07 +0100 Subject: [PATCH 8/9] Tidy --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 80450de..34fc6b4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ # `rsyslog_d` file template to use # # @param rsyslog_default_file_absolute_path -# `rsyslog_d` use the absolute template path +# `rsyslog_d` Use rsyslog_default_file as the absolute template path # # @param run_user # Which user rsyslog should run as From 00ecde3c0f756c9689ac34e946cfd1eb7746da40 Mon Sep 17 00:00:00 2001 From: Mike Woods Date: Wed, 21 May 2025 14:16:46 +0100 Subject: [PATCH 9/9] Correction --- templates/client/remote.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/client/remote.conf.erb b/templates/client/remote.conf.erb index 59d87cb..89baf36 100644 --- a/templates/client/remote.conf.erb +++ b/templates/client/remote.conf.erb @@ -38,7 +38,7 @@ <% else -%> <% dropaction = '' -%> <% end -%> -<%= pattern %> to <%= host %> via <%= server['protocol'].downcase %> on <%= port %> using <%=format_type %> format. +# Sending logs that match <%= pattern %> to <%= host %> via <%= server['protocol'].downcase %> on <%= port %> using <%=format_type %> format. <%= pattern %> <%= protocol %><%= host %>:<%= port %><%= format %> <%= dropaction %> <% end -%>