From ef7c703fe90c51ee9bfc5e3596c4981875137364 Mon Sep 17 00:00:00 2001 From: ml14tlc Date: Wed, 23 May 2018 23:04:01 +0200 Subject: [PATCH] proposal to add an array parameter to manage the filebeat modules (#168) --- README.md | 1 + manifests/config.pp | 10 +++++++++- manifests/init.pp | 2 ++ manifests/params.pp | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e49a4fd..0b55aaf 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,7 @@ Installs and configures filebeat. - `outputs`: [Hash] Will be converted to YAML for the required outputs section of the configuration (see documentation, and above) - `shipper`: [Hash] Will be converted to YAML to create the optional shipper section of the filebeat config (see documentation) - `logging`: [Hash] Will be converted to YAML to create the optional logging section of the filebeat config (see documentation) +- `modules`: [Array] Will be converted to YAML to create the optional modules section of the filebeat config (see documentation) - `conf_template`: [String] The configuration template to use to generate the main filebeat.yml config file. - `download_url`: [String] The URL of the zip file that should be downloaded to install filebeat (windows only) - `install_dir`: [String] Where filebeat should be installed (windows only) diff --git a/manifests/config.pp b/manifests/config.pp index 4122a90..1fc5d5f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -21,6 +21,7 @@ 'path' => "${filebeat::config_dir}/*.yml", }, 'shutdown_timeout' => $filebeat::shutdown_timeout, + 'modules' => $filebeat::modules, }, 'output' => $filebeat::outputs, 'shipper' => $filebeat::shipper, @@ -30,7 +31,7 @@ 'setup' => $filebeat::setup, }) } else { - $filebeat_config = delete_undef_values({ + $filebeat_config_temp = delete_undef_values({ 'shutdown_timeout' => $filebeat::shutdown_timeout, 'name' => $filebeat::beat_name, 'tags' => $filebeat::tags, @@ -52,6 +53,13 @@ 'runoptions' => $filebeat::run_options, 'processors' => $filebeat::processors, }) + # Add the 'modules' section if supported (version >= 5.2.0) + if versioncmp($filebeat::package_ensure, '5.2.0') >= 0 { + $filebeat_config = deep_merge($filebeat_config_temp, {'modules' => $filebeat::modules}) + } + else { + $filebeat_config = $filebeat_config_temp + } } if $::filebeat_version { diff --git a/manifests/init.pp b/manifests/init.pp index fe0ac56..a87c510 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,6 +29,7 @@ # @param outputs [Hash] Will be converted to YAML for the required outputs section of the configuration (see documentation, and above) # @param shipper [Hash] Will be converted to YAML to create the optional shipper section of the filebeat config (see documentation) # @param logging [Hash] Will be converted to YAML to create the optional logging section of the filebeat config (see documentation) +# @param modules [Array] Will be converted to YAML to create the optional modules section of the filebeat config (see documentation) # @param conf_template [String] The configuration template to use to generate the main filebeat.yml config file # @param download_url [String] The URL of the zip file that should be downloaded to install filebeat (windows only) # @param install_dir [String] Where filebeat should be installed (windows only) @@ -85,6 +86,7 @@ Array $processors = [], Hash $prospectors = {}, Hash $setup = {}, + Array $modules = [], Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $proxy_address = undef, # lint:ignore:140chars Stdlib::Absolutepath $filebeat_path = $filebeat::params::filebeat_path ) inherits filebeat::params { diff --git a/manifests/params.pp b/manifests/params.pp index 54668c5..74b0cef 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,6 +23,7 @@ $shipper = {} $logging = {} $run_options = {} + $modules = [] $kernel_fail_message = "${::kernel} is not supported by filebeat." $osfamily_fail_message = "${::osfamily} is not supported by filebeat." $conf_template = "${module_name}/pure_hash.yml.erb"