summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2013-09-23 16:10:56 -0400
committerJames Shubin <james@shubin.ca>2013-09-23 16:10:56 -0400
commit2aa4163f52eb55cdd376946ad05c5d74a45c14f8 (patch)
tree39dba26f2fab0809bde43b4813f307ce14c77697
parent17aff1a33a001cbb56735ff9f61a9bbcaa40cb04 (diff)
downloadpuppet-gluster-2aa4163f52eb55cdd376946ad05c5d74a45c14f8.tar.gz
puppet-gluster-2aa4163f52eb55cdd376946ad05c5d74a45c14f8.tar.xz
puppet-gluster-2aa4163f52eb55cdd376946ad05c5d74a45c14f8.zip
Add gluster version fact and operating-version templating.
Puppet-gluster now correctly picks the operating-version value from a table of known version -> value correspondences. Future value additions should be added to this table.
-rw-r--r--lib/facter/gluster_version.rb32
-rw-r--r--manifests/host.pp30
-rw-r--r--templates/glusterd.info.erb4
3 files changed, 62 insertions, 4 deletions
diff --git a/lib/facter/gluster_version.rb b/lib/facter/gluster_version.rb
new file mode 100644
index 0000000..4a84b25
--- /dev/null
+++ b/lib/facter/gluster_version.rb
@@ -0,0 +1,32 @@
+# Simple? gluster module by James
+# Copyright (C) 2010-2013+ James Shubin
+# Written by James Shubin <james@shubin.ca>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+require 'facter'
+
+gluster = '/usr/sbin/gluster'
+
+# create the fact if the gluster executable exists
+if File.exist?(gluster)
+ Facter.add('gluster_version') do
+ #confine :operatingsystem => %w{CentOS, RedHat, Fedora}
+ setcode {
+ Facter::Util::Resolution.exec(gluster+' --version | /usr/bin/head -1 | /bin/cut -d " " -f 2').chomp
+ }
+ end
+end
+
+# vim: ts=8
diff --git a/manifests/host.pp b/manifests/host.pp
index e85f971..cbccbf4 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -57,9 +57,33 @@ define gluster::host(
if "${valid_uuid}" == '' {
fail('No valid UUID exists yet!')
} else {
- # set a unique uuid per host
- # FIXME: set appropriate version based on gluster version
- $valid_version = '2'
+ # get shorter version string for loose matching...
+ $gluster_main_version = regsubst(
+ "${gluster_version}", # eg: 3.4.0
+ '^(\d+)\.(\d+)\.(\d+)$', # int.int.int
+ '\1.\2' # print int.int
+ )
+
+ # TODO: add additional values to this table...
+ $operating_version = "${gluster_version}" ? {
+ '' => '', # gluster not yet installed...
+ # specific version matches go here...
+ '3.4.0' => '2',
+ default => "${gluster_main_version}" ? {
+ # loose version matches go here...
+ #'3.3' => '1', # blank...
+ '3.4' => '2',
+ #'3.5' => '3', # guessing...
+ default => '-1', # unknown...
+ },
+ }
+
+ # this catches unknown gluster versions to add to table
+ if "${operating_version}" == '-1' {
+ warning("Gluster version '${gluster_version}' is unknown.")
+ }
+
+ # set a unique uuid per host, and operating version...
file { '/var/lib/glusterd/glusterd.info':
content => template('gluster/glusterd.info.erb'),
owner => root,
diff --git a/templates/glusterd.info.erb b/templates/glusterd.info.erb
index 23df83d..a02a379 100644
--- a/templates/glusterd.info.erb
+++ b/templates/glusterd.info.erb
@@ -1,2 +1,4 @@
UUID=<%= valid_uuid %>
-operating-version=<%= valid_version %>
+<% if operating_version != '' and operating_version != '-1' -%>
+operating-version=<%= operating_version %>
+<% end -%>