diff --git a/manifests/config.pp b/manifests/config.pp index 5d9e74d..79cca19 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -57,8 +57,8 @@ $validate_cmd = $filebeat::disable_config_test ? { true => undef, default => $major_version ? { - '5' => '/usr/share/filebeat/bin/filebeat -N -configtest -c %', - default => '/usr/share/filebeat/bin/filebeat -c % test config', + '5' => "${filebeat::filebeat_path} -N -configtest -c %", + default => "${filebeat::filebeat_path} -c % test config", }, } diff --git a/manifests/init.pp b/manifests/init.pp index 3827783..76c2f9d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -45,45 +45,46 @@ # @param prospectors_merge [Boolean] Whether $prospectors should merge all hiera sources, or use simple automatic parameter lookup # proxy_address [String] Proxy server to use for downloading files class filebeat ( - String $package_ensure = $filebeat::params::package_ensure, - Boolean $manage_repo = $filebeat::params::manage_repo, - Enum['5','6'] $major_version = $filebeat::params::major_version, - Variant[Boolean, Enum['stopped', 'running']] $service_ensure = $filebeat::params::service_ensure, - Boolean $service_enable = $filebeat::params::service_enable, - Optional[String] $service_provider = $filebeat::params::service_provider, - Optional[Integer] $repo_priority = undef, - Integer $spool_size = $filebeat::params::spool_size, - String $idle_timeout = $filebeat::params::idle_timeout, - Boolean $publish_async = $filebeat::params::publish_async, - String $registry_file = $filebeat::params::registry_file, - String $config_file = $filebeat::params::config_file, - Optional[String] $config_file_owner = $filebeat::params::config_file_owner, - Optional[String] $config_file_group = $filebeat::params::config_file_group, - String[4,4] $config_dir_mode = $filebeat::params::config_dir_mode, - String $config_dir = $filebeat::params::config_dir, - String[4,4] $config_file_mode = $filebeat::params::config_file_mode, - Optional[String] $config_dir_owner = $filebeat::params::config_dir_owner, - Optional[String] $config_dir_group = $filebeat::params::config_dir_group, - Boolean $purge_conf_dir = $filebeat::params::purge_conf_dir, - Hash $outputs = $filebeat::params::outputs, - Hash $shipper = $filebeat::params::shipper, - Hash $logging = $filebeat::params::logging, - Hash $run_options = $filebeat::params::run_options, - String $conf_template = $filebeat::params::conf_template, - Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $download_url = undef, # lint:ignore:140chars - Optional[String] $install_dir = $filebeat::params::install_dir, - String $tmp_dir = $filebeat::params::tmp_dir, - Integer $shutdown_timeout = $filebeat::params::shutdown_timeout, - String $beat_name = $filebeat::params::beat_name, - Array $tags = $filebeat::params::tags, - Integer $queue_size = $filebeat::params::queue_size, - Optional[Integer] $max_procs = $filebeat::params::max_procs, - Hash $fields = $filebeat::params::fields, - Boolean $fields_under_root = $filebeat::params::fields_under_root, - Boolean $disable_config_test = $filebeat::params::disable_config_test, - Hash $processors = {}, - Hash $prospectors = {}, - Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $proxy_address = undef # lint:ignore:140chars + String $package_ensure = $filebeat::params::package_ensure, + Boolean $manage_repo = $filebeat::params::manage_repo, + Enum['5','6'] $major_version = $filebeat::params::major_version, + Variant[Boolean, Enum['stopped', 'running']] $service_ensure = $filebeat::params::service_ensure, + Boolean $service_enable = $filebeat::params::service_enable, + Optional[String] $service_provider = $filebeat::params::service_provider, + Optional[Integer] $repo_priority = undef, + Integer $spool_size = $filebeat::params::spool_size, + String $idle_timeout = $filebeat::params::idle_timeout, + Boolean $publish_async = $filebeat::params::publish_async, + String $registry_file = $filebeat::params::registry_file, + String $config_file = $filebeat::params::config_file, + Optional[String] $config_file_owner = $filebeat::params::config_file_owner, + Optional[String] $config_file_group = $filebeat::params::config_file_group, + String[4,4] $config_dir_mode = $filebeat::params::config_dir_mode, + String $config_dir = $filebeat::params::config_dir, + String[4,4] $config_file_mode = $filebeat::params::config_file_mode, + Optional[String] $config_dir_owner = $filebeat::params::config_dir_owner, + Optional[String] $config_dir_group = $filebeat::params::config_dir_group, + Boolean $purge_conf_dir = $filebeat::params::purge_conf_dir, + Hash $outputs = $filebeat::params::outputs, + Hash $shipper = $filebeat::params::shipper, + Hash $logging = $filebeat::params::logging, + Hash $run_options = $filebeat::params::run_options, + String $conf_template = $filebeat::params::conf_template, + Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\ = [\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $download_url = undef, # lint:ignore:140chars + Optional[String] $install_dir = $filebeat::params::install_dir, + String $tmp_dir = $filebeat::params::tmp_dir, + Integer $shutdown_timeout = $filebeat::params::shutdown_timeout, + String $beat_name = $filebeat::params::beat_name, + Array $tags = $filebeat::params::tags, + Integer $queue_size = $filebeat::params::queue_size, + Optional[Integer] $max_procs = $filebeat::params::max_procs, + Hash $fields = $filebeat::params::fields, + Boolean $fields_under_root = $filebeat::params::fields_under_root, + Boolean $disable_config_test = $filebeat::params::disable_config_test, + Hash $processors = {}, + Hash $prospectors = {}, + Optional[Pattern[/^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-\.]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\ = [\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/]] $proxy_address = undef, # lint:ignore:140chars + Stdlib::Absolutepath $filebeat_path = $filebeat::params::filebeat_path ) inherits filebeat::params { include ::stdlib diff --git a/manifests/params.pp b/manifests/params.pp index 9dcf3b2..a44097e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,8 +4,6 @@ # # @summary Set a bunch of default parameters class filebeat::params { - $manage_repo = true - $major_version = '5' $service_ensure = running $service_enable = true $spool_size = 2048 @@ -29,6 +27,28 @@ $conf_template = "${module_name}/pure_hash.yml.erb" $disable_config_test = false + # These are irrelevant as long as the template is set based on the major_version parameter + # if versioncmp('1.9.1', $::rubyversion) > 0 { + # $conf_template = "${module_name}/filebeat.yml.ruby18.erb" + # } else { + # $conf_template = "${module_name}/filebeat.yml.erb" + # } + # + + # Archlinux has a proper package in the official repos + # we shouldn't manage the repo on it + case $facts['os']['family'] { + 'Archlinux': { + $manage_repo = false + $filebeat_path = '/usr/bin/filebeat' + $major_version = '6' + } + default: { + $manage_repo = true + $filebeat_path = '/usr/share/filebeat/bin/filebeat' + $major_version = '5' + } + } case $::kernel { 'Linux' : { $package_ensure = present diff --git a/manifests/prospector.pp b/manifests/prospector.pp index 818d862..26ff173 100644 --- a/manifests/prospector.pp +++ b/manifests/prospector.pp @@ -57,7 +57,7 @@ group => 'root', mode => $::filebeat::config_file_mode, content => template("${module_name}/${prospector_template}"), - validate_cmd => '/usr/share/filebeat/bin/filebeat -N -configtest -c %', + validate_cmd => "${filebeat::filebeat_path} -N -configtest -c %", notify => Service['filebeat'], } } else { @@ -70,7 +70,6 @@ content => template("${module_name}/${prospector_template}"), notify => Service['filebeat'], } - } } diff --git a/metadata.json b/metadata.json index e364458..bf8f5de 100644 --- a/metadata.json +++ b/metadata.json @@ -78,6 +78,9 @@ "2012", "2012 R2" ] + }, + { + "operatingsystem": "Archlinux" } ], "requirements": [ diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index b89b946..984b25a 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -15,11 +15,18 @@ let(:major_version) { version } let(:validate_cmd) do + path = case os_facts[:os]['family'] + when 'Archlinux' + '/usr/bin/filebeat' + else + '/usr/share/filebeat/bin/filebeat' + end + case major_version when 5 - '/usr/share/filebeat/bin/filebeat -N -configtest -c %' + "#{path} -N -configtest -c %" else - '/usr/share/filebeat/bin/filebeat -c % test config' + "#{path} -c % test config" end end diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index d426819..f8b1807 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -19,7 +19,7 @@ case os_facts[:kernel] when 'Linux' it { is_expected.to contain_class('filebeat::install::linux') } - it { is_expected.to contain_class('filebeat::repo') } + it { is_expected.to contain_class('filebeat::repo') } unless os_facts[:os]['family'] == 'Archlinux' it { is_expected.not_to contain_class('filebeat::install::windows') } when 'Windows' diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 3016b65..75a59e4 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -12,7 +12,7 @@ case os_facts[:kernel] when 'Linux' - it { is_expected.to compile } + it { is_expected.to compile } unless os_facts[:os]['family'] == 'Archlinux' case os_facts[:osfamily] when 'Debian' it {