forked from pcfens/puppet-filebeat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilebeat_version.rb
35 lines (35 loc) · 1.93 KB
/
filebeat_version.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'facter'
Facter.add('filebeat_version') do
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? 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? 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? 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? 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? or filebeat_version.include? 'error'
filebeat_version = Facter::Util::Resolution.exec('"c:\Program Files\Filebeat\filebeat.exe" --version')
end
end
setcode do
filebeat_version.nil? ? false : %r{^filebeat version ([^\s]+)?}.match(filebeat_version)[1]
end
end