summaryrefslogtreecommitdiffstats
path: root/manifests/simple.pp
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2013-10-10 19:35:20 -0400
committerJames Shubin <james@shubin.ca>2013-10-10 22:54:33 -0400
commitdb0e06f48d09f94f92fb78087a717b79c9da6eac (patch)
treeb6045e23cf1c3615d20ed07cc25186d1c094cf80 /manifests/simple.pp
parentb9153d8859b11d9672ba285dc0f281b0bdf78119 (diff)
downloadpuppet-gluster-db0e06f48d09f94f92fb78087a717b79c9da6eac.tar.gz
puppet-gluster-db0e06f48d09f94f92fb78087a717b79c9da6eac.tar.xz
puppet-gluster-db0e06f48d09f94f92fb78087a717b79c9da6eac.zip
Automatic brick ordering and finite state machine support.
This patch adds preliminary FSM support. This will be used and abused more extensively in later patches. Automatic brick ordering is an advanced feature and is meant for experienced puppet users. Changing the available bricks before the cluster is built is not currently supported. For that type of magic, please wait for gluster::elastic. This feature expects that you name your bricks and hosts intelligently. Future patches will recommend a specific nomenclature, but for now as long as the brick paths and hostnames follow a padded, incrementing integer pattern, with a common prefix, you shouldn't see any problems.
Diffstat (limited to 'manifests/simple.pp')
-rw-r--r--manifests/simple.pp89
1 files changed, 89 insertions, 0 deletions
diff --git a/manifests/simple.pp b/manifests/simple.pp
new file mode 100644
index 0000000..4f34cb9
--- /dev/null
+++ b/manifests/simple.pp
@@ -0,0 +1,89 @@
+# GlusterFS 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/>.
+
+class gluster::simple(
+ $path = '',
+ $volume = 'puppet', # NOTE: this can be a list...
+ $replica = 1,
+ $stripe = 1, # TODO: not fully implemented in puppet-gluster
+ $vip = '' # strongly recommended
+) {
+ include gluster::vardir
+
+ #$vardir = $::gluster::vardir::module_vardir # with trailing slash
+ $vardir = regsubst($::gluster::vardir::module_vardir, '\/$', '')
+
+ if "${path}" == '' {
+ file { "${vardir}/data/":
+ ensure => directory, # make sure this is a directory
+ recurse => false, # don't recurse into directory
+ purge => false, # don't purge unmanaged files
+ force => false, # don't purge subdirs and links
+ require => File["${vardir}/"],
+ }
+ }
+
+ $chosen_path = "${path}" ? {
+ '' => "${vardir}/data/",
+ default => "${path}",
+ }
+
+ $valid_path = sprintf("%s/", regsubst($chosen_path, '\/$', ''))
+
+ notify { 'gluster::simple':
+ message => 'You are using gluster::simple !',
+ }
+
+ if "${vip}" == '' {
+ # If you don't use a VIP, things will be racy, but could mostly
+ # work. If you run puppet manually, then a vip isn't necessary.
+ # see: http://ttboj.wordpress.com/2012/08/23/how-to-avoid-cluster-race-conditions-or-how-to-implement-a-distributed-lock-manager-in-puppet/
+ warning('It is highly recommended to use a VIP.')
+ }
+
+ class { '::gluster::server':
+ vip => "${vip}",
+ #zone => 'net', # defaults to net
+ shorewall => true,
+ }
+
+ @@gluster::host { "${::fqdn}":
+ }
+ Gluster::Host <<||>>
+
+ @@gluster::brick { "${::fqdn}:${valid_path}":
+ areyousure => true,
+ }
+
+ Gluster::Brick <<||>>
+
+ gluster::volume { $volume:
+ replica => $replica,
+ stripe => $stripe,
+ # NOTE: with this method you do not choose the order of course!
+ # the gluster_fqdns fact is alphabetical, but not complete till
+ # at least a puppet run of each node has occured. watch out for
+ # partial clusters missing some of the nodes with bad ordering!
+ #bricks => split(inline_template("<%= gluster_fqdns.split(',').collect {|x| x+':${valid_path}' }.join(',') %>"), ','),
+ # the only semi-safe way is the new built in automatic collect:
+ bricks => true, # automatic brick collection...
+ start => true,
+ }
+ Gluster::Volume <<||>>
+}
+
+# vim: ts=8