Skip to content

Commit dc9f3c6

Browse files
authored
Merge pull request #476 from Valantin/fix-facts
clean esyrsa fact code
2 parents 90ab22f + 3a95d10 commit dc9f3c6

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

lib/facter/easyrsa.rb

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,21 @@
33
Facter.add(:easyrsa) do
44
confine kernel: 'Linux'
55
setcode do
6-
binaryv3 = ''
7-
operatingsystem = Facter.value(:operatingsystem)
8-
operatingsystemrelease = Facter.value(:operatingsystemrelease)
6+
binary = case Facter.value[:os]['family']
7+
when 'RedHat'
8+
'/usr/share/easy-rsa/3/easyrsa'
9+
when 'Debian'
10+
'/usr/share/easy-rsa/easyrsa'
11+
when 'FreeBSD'
12+
'/usr/local/share/easy-rsa/easyrsa'
13+
when 'Solaris'
14+
'/opt/local/bin/easyrsa'
15+
else
16+
''
17+
end
918

10-
case operatingsystem
11-
when %r{RedHat|CentOS|Amazon|Rocky|AlmaLinux|OracleLinux}
12-
binaryv3 = '/usr/share/easy-rsa/3/easyrsa'
13-
when %r{Ubuntu|Debian}
14-
binaryv3 = case operatingsystemrelease
15-
when %r{|11|12|22.04|24.04}
16-
'/usr/share/easy-rsa/easyrsa'
17-
else
18-
'/usr/share/doc/openvpn/examples/easy-rsa/3.0/easyrsa'
19-
end
20-
when %r{FreeBSD}
21-
binaryv3 = '/usr/local/share/easy-rsa/easyrsa'
22-
when %r{Solaris}
23-
binaryv3 = '/opt/local/bin/easyrsa'
24-
end
25-
26-
if File.exist? binaryv3
27-
data = Facter::Core::Execution.execute("#{binaryv3} help")
19+
if File.exist? binary
20+
data = Facter::Core::Execution.execute("#{binary} help")
2821
version = '3.0' if data.gsub!(%r{Easy-RSA 3 usage}, '')
2922
elsif Facter::Util::Resolution.which('easyrsa')
3023
data = Facter::Core::Execution.execute('easyrsa help')

0 commit comments

Comments
 (0)