Skip to content

Commit

Permalink
Cover case when config file is in different location than binary (#342)
Browse files Browse the repository at this point in the history
Check if result of exec contains "error". This covers cases when filebeat config is not in the same directory
  • Loading branch information
r-savcenko authored Jan 25, 2024
1 parent 3573cf3 commit 8bdc573
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/facter/filebeat_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8bdc573

Please sign in to comment.