From 8bdc5731a3860f42b54469439bcad8c3bf70abb4 Mon Sep 17 00:00:00 2001 From: r-savcenko Date: Thu, 25 Jan 2024 21:11:30 +0200 Subject: [PATCH] Cover case when config file is in different location than binary (#342) Check if result of exec contains "error". This covers cases when filebeat config is not in the same directory --- lib/facter/filebeat_version.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/facter/filebeat_version.rb b/lib/facter/filebeat_version.rb index e03358b..bbeb821 100644 --- a/lib/facter/filebeat_version.rb +++ b/lib/facter/filebeat_version.rb @@ -3,29 +3,29 @@ confine 'kernel' => ['FreeBSD', 'OpenBSD', 'Linux', 'Windows', 'SunOS'] if File.executable?('/usr/bin/filebeat') filebeat_version = Facter::Util::Resolution.exec('/usr/bin/filebeat version') - if filebeat_version.empty? + if filebeat_version.empty? or filebeat_version.include? 'error' filebeat_version = Facter::Util::Resolution.exec('/usr/bin/filebeat --version') end elsif File.executable?('/usr/local/bin/filebeat') filebeat_version = Facter::Util::Resolution.exec('/usr/local/bin/filebeat version') - if filebeat_version.empty? + if filebeat_version.empty? or filebeat_version.include? 'error' filebeat_version = Facter::Util::Resolution.exec('/usr/local/bin/filebeat --version') end elsif File.executable?('/opt/local/bin/filebeat') filebeat_version = Facter::Util::Resolution.exec('/opt/local/bin/filebeat version') - if filebeat_version.empty? + if filebeat_version.empty? or filebeat_version.include? 'error' filebeat_version = Facter::Util::Resolution.exec('/opt/local/bin/filebeat --version') end elsif File.executable?('/usr/share/filebeat/bin/filebeat') filebeat_version = Facter::Util::Resolution.exec('/usr/share/filebeat/bin/filebeat --version') elsif File.executable?('/usr/local/sbin/filebeat') filebeat_version = Facter::Util::Resolution.exec('/usr/local/sbin/filebeat version') - if filebeat_version.empty? + if filebeat_version.empty? or filebeat_version.include? 'error' filebeat_version = Facter::Util::Resolution.exec('/usr/local/sbin/filebeat --version') end elsif File.exist?('c:\Program Files\Filebeat\filebeat.exe') filebeat_version = Facter::Util::Resolution.exec('"c:\Program Files\Filebeat\filebeat.exe" version') - if filebeat_version.empty? + if filebeat_version.empty? or filebeat_version.include? 'error' filebeat_version = Facter::Util::Resolution.exec('"c:\Program Files\Filebeat\filebeat.exe" --version') end end