Skip to content

Commit

Permalink
The version fact currently supplies the available redis version
Browse files Browse the repository at this point in the history
regardless of whether it's installed or not. The result is that
all nodes contain a fact that implies that the latest available
redis version seems to be installed.

This change switches from using yum to rpm to query the locally
installed package database. It has the added benefit of not
querying yum, which can be costly.

Addresses fsalum#39 in part.
  • Loading branch information
pall-valmundsson committed Mar 29, 2015
1 parent 77fc677 commit 8c71b33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/facter/redis_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@

setcode do

yum = `which yum 2> /dev/null`.chomp
if yum == ''
yum = '/usr/bin/yum'
rpm = `which rpm 2> /dev/null`.chomp
if rpm == ''
rpm = '/usr/bin/rpm'
end

redis_version = Facter::Util::Resolution.exec('/usr/sbin/redis-server --version')
if redis_version.nil?
redis_version = Facter::Util::Resolution.exec(yum+" info redis 2> /dev/null | /bin/grep '^Version' | /bin/awk -F ':' '{printf(\"%s\",$2)}' | sort -nr | head -1")
redis_version = Facter::Util::Resolution.exec(rpm+" -q --queryformat '%{version}\\n' redis | grep -v 'not installed' | sort -nr | head -1")
end

case redis_version
Expand All @@ -64,7 +64,7 @@
#set version to 2.2
redis_version = '2.2.x'
else
redis_version = 'nil'
redis_version = nil
end
redis_version
end
Expand Down

0 comments on commit 8c71b33

Please sign in to comment.