summaryrefslogtreecommitdiff
path: root/lib/facter/couchdb_version.rb
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2015-06-11 14:19:28 +0200
committervarac <varacanero@zeromail.org>2015-06-11 14:19:35 +0200
commita2b804ac1dda1ed52f3c8194447b75c145406791 (patch)
treebf54907ccdc391063612a570d049c643e00d0b41 /lib/facter/couchdb_version.rb
parent23b557c6fb07929a9b04e5fb75375a85a4734370 (diff)
added facts couchdb_version and couchdb_pwhash_alg
couchdb v1.3 changed the default pw hashing algorithm from sha1 to pbkdf2, see http://docs.couchdb.org/en/1.4.x/configuring.html the "couchdb_pwhash_alg" fact shows the currently used algorithm by checking the "couchdb_version" fact.
Diffstat (limited to 'lib/facter/couchdb_version.rb')
-rw-r--r--lib/facter/couchdb_version.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/facter/couchdb_version.rb b/lib/facter/couchdb_version.rb
new file mode 100644
index 0000000..3a72116
--- /dev/null
+++ b/lib/facter/couchdb_version.rb
@@ -0,0 +1,34 @@
+require 'facter'
+
+def deb_installed_version ( name )
+ # returns an empty string if package is not installed,
+ # otherwise the version
+
+ version = `apt-cache policy #{name} | grep Installed 2>&1`
+ version.slice! " Installed: "
+ version.slice! "(none)"
+ return version.strip.chomp
+end
+
+def couchdb_version
+ bigcouch = deb_installed_version("bigcouch")
+ if bigcouch.empty?
+ couchdb = deb_installed_version("couchdb")
+ if couchdb.empty?
+ version = 'n/a'
+ else
+ version = couchdb
+ end
+ else
+ # bigcouch is currently only available in one version (0.4.2),
+ # which includes couchdb 1.1.1
+ version = '1.1.1'
+ end
+ return version
+end
+
+Facter.add(:couchdb_version) do
+ setcode do
+ couchdb_version
+ end
+end