diff options
author | James Shubin <james@shubin.ca> | 2014-12-16 13:01:49 -0500 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2014-12-16 13:24:27 -0500 |
commit | 43c60d2ddd6f57d2117585dc149de6653bdabd4b (patch) | |
tree | 92bc51611414500970254ad88d3e5fb2fe0f7a86 /lib | |
parent | a5a2a412c64a9902954b25c9b9f4c1ac9be260fb (diff) | |
download | puppet-gluster-43c60d2ddd6f57d2117585dc149de6653bdabd4b.tar.gz puppet-gluster-43c60d2ddd6f57d2117585dc149de6653bdabd4b.tar.xz puppet-gluster-43c60d2ddd6f57d2117585dc149de6653bdabd4b.zip |
Replace the hard-coded gluster operating version table with hiera data.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/gluster_version.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/facter/gluster_version.rb b/lib/facter/gluster_version.rb index a3df7bc..508aa79 100644 --- a/lib/facter/gluster_version.rb +++ b/lib/facter/gluster_version.rb @@ -29,10 +29,23 @@ cut = `which cut 2> /dev/null`.chomp # create the fact if the gluster executable exists if File.exist?(gluster) + cmd = gluster+' --version | /usr/bin/head -1 | '+cut+' -d " " -f 2' + version = `#{cmd}`.chomp + match = /^(\d+)\.(\d+)\.(\d+)$/.match("#{version}") + if not match.nil? + major_version = "#{match[1]}.#{match[2]}" + Facter.add('gluster_major_version') do + #confine :operatingsystem => %w{CentOS, RedHat, Fedora} + setcode { + major_version + } + end + end + Facter.add('gluster_version') do #confine :operatingsystem => %w{CentOS, RedHat, Fedora} setcode { - Facter::Util::Resolution.exec(gluster+' --version | /usr/bin/head -1 | '+cut+' -d " " -f 2').chomp + version } end end |