Skip to content

Commit

Permalink
add archlinux support (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak authored and pcfens committed Dec 21, 2017
1 parent 2aa7807 commit f162266
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 49 deletions.
4 changes: 2 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}

Expand Down
79 changes: 40 additions & 39 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions manifests/prospector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -70,7 +70,6 @@
content => template("${module_name}/${prospector_template}"),
notify => Service['filebeat'],
}

}
}

Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
"2012",
"2012 R2"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
Expand Down
11 changes: 9 additions & 2 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f162266

Please sign in to comment.