summaryrefslogtreecommitdiff
path: root/puppet/modules/couchdb/lib/facter/couchdb_version.rb
diff options
context:
space:
mode:
authorMicah <micah@leap.se>2016-05-24 10:19:27 -0400
committerMicah <micah@leap.se>2016-05-24 10:19:27 -0400
commit8f1fd7c7e042539f3095541b8859276e4dad6629 (patch)
tree864440ba7ce27d8d1fc8d7a504d554bb2fcd2817 /puppet/modules/couchdb/lib/facter/couchdb_version.rb
parent9721c9eeb21f027456b149764d300a11e301c8ee (diff)
parentaf6fdd31fb961fc1b7f408f51001e7a6d192a58a (diff)
Merge commit 'af6fdd31fb961fc1b7f408f51001e7a6d192a58a' as 'puppet/modules/couchdb'
Diffstat (limited to 'puppet/modules/couchdb/lib/facter/couchdb_version.rb')
-rw-r--r--puppet/modules/couchdb/lib/facter/couchdb_version.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/puppet/modules/couchdb/lib/facter/couchdb_version.rb b/puppet/modules/couchdb/lib/facter/couchdb_version.rb
new file mode 100644
index 00000000..3a721169
--- /dev/null
+++ b/puppet/modules/couchdb/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