From 41de778b0a802dc30a41436616bd2454a46c5f3d Mon Sep 17 00:00:00 2001 From: Ralf Bosz Date: Fri, 24 Nov 2023 13:21:30 +0100 Subject: [PATCH 1/4] Remove deprecated validate_* functions This is the same as #65 but now using datatypes instead of the validate_legacy function. --- manifests/init.pp | 62 +++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c15bda6..f31464b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,39 +25,37 @@ # @param tmp_dir [String] Where winlogbeat should be temporarily downloaded to so it can be installed # @param event_logs [Hash] Event_logs that will be forwarded. # @param event_logs_merge [Boolean] Whether $event_logs should merge all hiera sources, or use simple automatic parameter lookup - +# class winlogbeat ( - $major_version = undef, - $package_ensure = $winlogbeat::params::package_ensure, - $service_ensure = $winlogbeat::params::service_ensure, - $service_enable = $winlogbeat::params::service_enable, - $service_provider = $winlogbeat::params::service_provider, - $registry_file = $winlogbeat::params::registry_file, - $config_file = $winlogbeat::params::config_file, - $outputs = $winlogbeat::params::outputs, - $shipper = $winlogbeat::params::shipper, - $logging = $winlogbeat::params::logging, - $run_options = $winlogbeat::params::run_options, - $conf_template = undef, - $download_url = undef, - $install_dir = $winlogbeat::params::install_dir, - $tmp_dir = $winlogbeat::params::tmp_dir, + Optional[String] $major_version = undef, + String $package_ensure = $winlogbeat::params::package_ensure, + String $service_ensure = $winlogbeat::params::service_ensure, + Boolean $service_enable = $winlogbeat::params::service_enable, + Optional[String] $service_provider = $winlogbeat::params::service_provider, + String $registry_file = $winlogbeat::params::registry_file, + Stdlib::Windowspath $config_file = $winlogbeat::params::config_file, + Hash $outputs = $winlogbeat::params::outputs, + Hash $shipper = $winlogbeat::params::shipper, + Hash $logging = $winlogbeat::params::logging, + Hash $run_options = $winlogbeat::params::run_options, + Optional[String] $conf_template = undef, + Optional[Stdlib::HTTPUrl] $download_url = undef, + String $install_dir = $winlogbeat::params::install_dir, + String $tmp_dir = $winlogbeat::params::tmp_dir, #### v5 only #### - $use_generic_template = $winlogbeat::params::use_generic_template, - $beat_name = $winlogbeat::params::beat_name, - $tags = $winlogbeat::params::tags, - $queue_size = $winlogbeat::params::queue_size, - $max_procs = $winlogbeat::params::max_procs, - $fields = $winlogbeat::params::fields, - $fields_under_root = $winlogbeat::params::fields_under_root, - $metrics = undef, + Boolean $use_generic_template = $winlogbeat::params::use_generic_template, + Stdlib::Fqdn $beat_name = $winlogbeat::params::beat_name, + Array $tags = $winlogbeat::params::tags, + Integer $queue_size = $winlogbeat::params::queue_size, + Optional[Integer] $max_procs = $winlogbeat::params::max_procs, + Hash $fields = $winlogbeat::params::fields, + Boolean $fields_under_root = $winlogbeat::params::fields_under_root, + Optional[Hash] $metrics = undef, #### End v5 only #### - $event_logs = {}, - $event_logs_merge = false, - $proxy_address = undef, + Hash $event_logs = {}, + Boolean $event_logs_merge = false, + Optional[Stdlib::HTTPUrl] $proxy_address = undef, ) inherits winlogbeat::params { - validate_bool($event_logs_merge) - if $major_version == undef and getvar('winlogbeat_version') == undef { $real_version = '5' } elsif $major_version == undef and versioncmp($facts['winlogbeat_version'], '5.0.0') >= 0 { @@ -99,12 +97,6 @@ warning('You\'ve specified a non-standard config_file location - winlogbeat may fail to start unless you\'re doing something to fix this') } - validate_hash($outputs, $logging, $event_logs_final) - validate_string($registry_file, $package_ensure) - - if(!empty($proxy_address)) { - validate_re($proxy_address, ['^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$'], 'ERROR: You must enter a proxy url in a valid format i.e. http://proxy.net:3128') - } contain winlogbeat::install contain winlogbeat::config contain winlogbeat::service From c660fe8bd780af6da35f756de6dd81d9b593d765 Mon Sep 17 00:00:00 2001 From: Ralf Bosz Date: Wed, 13 Dec 2023 06:38:08 +0100 Subject: [PATCH 2/4] Replace the has_key function The has_key function is deprecated, using an internal Puppet function instead. --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 0c659a8..1a58333 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -25,7 +25,7 @@ } if (versioncmp($winlogbeat::real_version, '7') < 0) { $winlogbeat_config['winlogbeat']['event_logs'].each | $k,$v | { - if has_key($v,'processors') { + if 'processors' in $v { fail("winlogbeat versions < 7 do not support processors key within an event_log entry\n 'processors' key present in ${k}") } } From 6e86d75421f6a18dcd9802b272bb6854492be5f1 Mon Sep 17 00:00:00 2001 From: Ralf Bosz Date: Fri, 22 Dec 2023 10:21:17 +0100 Subject: [PATCH 3/4] Update manifests/init.pp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Romain Tartière --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index f31464b..5e8bd97 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,7 +46,7 @@ Boolean $use_generic_template = $winlogbeat::params::use_generic_template, Stdlib::Fqdn $beat_name = $winlogbeat::params::beat_name, Array $tags = $winlogbeat::params::tags, - Integer $queue_size = $winlogbeat::params::queue_size, + Integer[1] $queue_size = $winlogbeat::params::queue_size, Optional[Integer] $max_procs = $winlogbeat::params::max_procs, Hash $fields = $winlogbeat::params::fields, Boolean $fields_under_root = $winlogbeat::params::fields_under_root, From 43e6c26fb3c3e3a000c587f3a74ee10aeaa6d9b0 Mon Sep 17 00:00:00 2001 From: Ralf Bosz Date: Thu, 1 Feb 2024 10:06:32 +0100 Subject: [PATCH 4/4] Add suggestions made by @smortex --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5e8bd97..f31464b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,7 +46,7 @@ Boolean $use_generic_template = $winlogbeat::params::use_generic_template, Stdlib::Fqdn $beat_name = $winlogbeat::params::beat_name, Array $tags = $winlogbeat::params::tags, - Integer[1] $queue_size = $winlogbeat::params::queue_size, + Integer $queue_size = $winlogbeat::params::queue_size, Optional[Integer] $max_procs = $winlogbeat::params::max_procs, Hash $fields = $winlogbeat::params::fields, Boolean $fields_under_root = $winlogbeat::params::fields_under_root,