Debian Codegraph @

lib/facter/haproxy_version.rb

raw
1 # frozen_string_literal: true
2
3 # Fact: haproxy_version
4 #
5 # Purpose: get haproxy's current version
6 #
7 # Resolution:
8 # Uses haproxy's -v flag and parses the result from 'version'
9 #
10 # Caveats:
11 # none
12 #
13 # Notes:
14 # None
15 # workaround Ubuntu 12.04: https://tickets.puppetlabs.com/browse/MODULES-2881
16 if defined?(Facter::Core::Execution.which) && Facter::Core::Execution.which('haproxy')
17 Facter.add('haproxy_version') do
18 haproxy_version_cmd = 'haproxy -v 2>&1'
19 haproxy_version_result = Facter::Core::Execution.execute(haproxy_version_cmd)
20 setcode do
21 haproxy_version_result.to_s.lines.first.strip.split(%r{HA?.Proxy})[1].strip.split(%r{version})[1].strip.split(%r{((\d+\.){2,}\d+).*})[1]
22 end
23 end
24 end