summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-03-24 14:25:06 -0400
committerJames Shubin <james@shubin.ca>2014-03-24 14:33:45 -0400
commitcc6db62e5a7ee0b783f59755a30d8cef134eb35a (patch)
tree05015ab65d8c896b33d0caa3bdab68b2ce39c052
parent7c423fa725f804e15060fce85208e5861e970c6d (diff)
downloadpuppet-gluster-cc6db62e5a7ee0b783f59755a30d8cef134eb35a.tar.gz
puppet-gluster-cc6db62e5a7ee0b783f59755a30d8cef134eb35a.tar.xz
puppet-gluster-cc6db62e5a7ee0b783f59755a30d8cef134eb35a.zip
Add per brick defaults to gluster::simple for easier [physical] clusters.
I've had most of this patch in my head for at least a week, and I finally got the time to implement it! If you are building a symmetrical cluster, that has consistent device naming across all of the hosts, then this patch is the magic that should make your life _significantly_ easier. (*cough, cough*: Ben England...) In the corner case that some of your device have different names, you can still use this feature in conjunction with the other parameters to first set global defaults, and then override as needed. If you don't specify an overriding parameter (such as $count) then the number of elements in this array will be used as the brick count! Please note that this patch provides the $brick_params_defaults option which is different from the $brick_param_defaults option which will still work, and is useful in conjunction with this option as the way to set brick defaults across the whole cluster. For more questions you'll be happy to see that this patch comes with documentation and example updates.
-rw-r--r--DOCUMENTATION.md23
-rw-r--r--examples/gluster-simple-physical-example-best.pp28
-rw-r--r--manifests/simple.pp56
-rw-r--r--puppet-gluster-documentation.pdfbin224340 -> 226497 bytes
4 files changed, 87 insertions, 20 deletions
diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md
index c22a096..a8eea4a 100644
--- a/DOCUMENTATION.md
+++ b/DOCUMENTATION.md
@@ -474,6 +474,29 @@ $brick_param_defaults = {
}
```
+####`brick_params_defaults`
+This parameter lets you specify a list of defaults to use when creating each
+brick. Each element in the list represents a different brick. The value of each
+element is a hash with the actual defaults that you'd like to use for creating
+that brick. If you do not specify a brick count by any other method, then the
+number of elements in this array will be used as the brick count. This is very
+useful if you have consistent device naming across your entire cluster, because
+you can very easily specify the devices and brick counts once for all hosts. If
+for some reason a particular device requires unique values, then it can be set
+manually with the _brick_params_ parameter. Please note the spelling of this
+parameter. It is not the same as the _brick_param_defaults_ parameter which is
+a global defaults parameter which will apply to all bricks.
+The format of this parameter might look like:
+
+```bash
+$brick_params_defaults = [
+ {'dev' => '/dev/sdb'},
+ {'dev' => '/dev/sdc'},
+ {'dev' => '/dev/sdd'},
+ {'dev' => '/dev/sde'},
+]
+```
+
####`setgroup`
Set a volume property group. The two most common or well-known groups are the
_virt_ group, and the _small-file-perf_ group. This functionality is emulated
diff --git a/examples/gluster-simple-physical-example-best.pp b/examples/gluster-simple-physical-example-best.pp
new file mode 100644
index 0000000..06be1ed
--- /dev/null
+++ b/examples/gluster-simple-physical-example-best.pp
@@ -0,0 +1,28 @@
+#
+# really simple gluster setup for physical provisioning.
+# (yeah, that's it-- for iron!)
+#
+
+node /^annex\d+$/ { # annex{1,2,..N}
+
+ class { '::gluster::simple':
+ replica => 2,
+ vip = '192.168.1.42',
+ vrrp = true,
+ # NOTE: _each_ host will have four bricks with these devices...
+ brick_params_defaults = [ # note the spelling and type...
+ {'dev' => '/dev/sdb'},
+ {'dev' => '/dev/sdc'},
+ {'dev' => '/dev/sdd'},
+ {'dev' => '/dev/sde'},
+ ],
+ brick_param_defaults => { # every brick will use these...
+ lvm => false,
+ xfs_inode64 => true,
+ force => true,
+ },
+ #brick_params => {}, # NOTE: you can also use this option to
+ # override a particular fqdn with the options that you need to!
+ }
+}
+
diff --git a/manifests/simple.pp b/manifests/simple.pp
index 6bc6c11..1317029 100644
--- a/manifests/simple.pp
+++ b/manifests/simple.pp
@@ -28,22 +28,8 @@ class gluster::simple(
$repo = true,
$count = 0, # 0 means build 1 brick, unless $brick_params exists...
$brick_params = {}, # this sets the brick count when $count is 0...
- # usage notes: the $brick_params parameter might look like:
- # {
- # fqdn1 => [
- # {dev => '/dev/disk/by-uuid/505e0286-8e21-49b4-a9b2-894777c69962'},
- # {dev => '/dev/sde', partition => false},
- # ],
- # fqdn2 => [{dev => '/dev/disk/by-path/pci-0000:02:00.0-scsi-0:1:0:0', raid_su => 256, raid_sw => 10}],
- # fqdnN => [...],
- # }
$brick_param_defaults = {}, # these always get used to build bricks
- # usage notes: the $brick_param_defaults might look like:
- # {
- # lvm => false,
- # xfs_inode64 => true,
- # force => true,
- # }
+ $brick_params_defaults = [], # array of hashes to use as brick count
$setgroup = '', # pick a volume property group to set, eg: virt
$ping = true, # use fping or not?
$baseport = '', # specify base port option as used in glusterd.vol file
@@ -78,6 +64,7 @@ class gluster::simple(
default => ["${volume}"],
}
+ # if this is a hash, then it's used as the defaults for all the bricks!
validate_hash($brick_param_defaults)
# in someone explicitly added this value, then don't overwrite it...
if has_key($brick_param_defaults, 'areyousure') {
@@ -87,6 +74,12 @@ class gluster::simple(
$valid_brick_param_defaults = merge($brick_param_defaults, $areyousure)
}
+ # if this is an array, then each element is the default for each brick!
+ # if this is an array, then the number of elements is the brick count!!
+ validate_array($brick_params_defaults)
+ # TODO: check that each element of array is a valid hash!
+ $valid_brick_params_defaults = $brick_params_defaults
+
notify { 'gluster::simple':
message => 'You are using gluster::simple !',
}
@@ -129,16 +122,39 @@ class gluster::simple(
if has_key($brick_params, "${::fqdn}") {
# here some wizardry happens...
$brick_params_list = $brick_params["${::fqdn}"]
+ $brick_params_list_length = inline_template('<%= @brick_params_list.length %>')
+ $brick_params_defaults_length = inline_template('<%= @valid_brick_params_defaults.length %>')
+
$valid_count = "${count}" ? {
- '0' => inline_template('<%= @brick_params_list.length %>'),
+ '0' => "${brick_params_list_length}" ? {
+ '0' => "${brick_params_defaults_length}" ? {
+ '0' => 1, # if all are empty...
+ default => "${brick_params_defaults_length}",
+ },
+ default => "${brick_params_list_length}",
+ },
default => $count,
}
validate_array($brick_params_list)
- $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {'${::fqdn}:${valid_path}brick' + (i+1).to_s.rjust(7, '0') + '/' => ((i < @brick_params_list.length) ? @brick_params_list[i] : {})}.merge(h) }.to_yaml %>")
+
+ # NOTE: I've kept this template split as two comment chunks for
+ # readability. Puppet needs to fix this issue somehow. Creating
+ # a separate template removes the logic from the code, but as a
+ # large inline template, it's hard to read/write the logic!
+ #DEFAULTS = (((i < @valid_brick_params_defaults.length) and @valid_brick_params_defaults[i].is_a?(Hash)) ? @valid_brick_params_defaults[i] : {})
+ #$yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {'${::fqdn}:${valid_path}brick' + (i+1).to_s.rjust(7, '0') + '/' => DEFAULTS.merge((i < @brick_params_list.length) ? @brick_params_list[i] : {})}.merge(h) }.to_yaml %>")
+ $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {'${::fqdn}:${valid_path}brick' + (i+1).to_s.rjust(7, '0') + '/' => (((i < @valid_brick_params_defaults.length) and @valid_brick_params_defaults[i].is_a?(Hash)) ? @valid_brick_params_defaults[i] : {}).merge((i < @brick_params_list.length) ? @brick_params_list[i] : {})}.merge(h) }.to_yaml %>")
} else {
- # here we base our brick list on the $count variable alone...
+ # TODO: this second branch is really just a special case of the
+ # above branch and can probably be merged without much incident
+ $brick_params_defaults_length = inline_template('<%= @valid_brick_params_defaults.length %>')
+ # here we base our brick list on the $count variable or the
+ # brick_params_defaults length if it is available...
$valid_count = "${count}" ? {
- '0' => 1, # 0 means undefined, so use the default
+ '0' => "${brick_params_defaults_length}" ? {
+ '0' => 1, # 0 means undefined, so use the default
+ default => "${brick_params_defaults_length}",
+ },
default => $count,
}
$brick_params_list = "${valid_count}" ? {
@@ -146,7 +162,7 @@ class gluster::simple(
'1' => ["${::fqdn}:${valid_path}"],
default => split(inline_template("<%= (1..@valid_count.to_i).collect{|i| '${::fqdn}:${valid_path}brick' + i.to_s.rjust(7, '0') + '/' }.join(',') %>"), ','),
}
- $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {@brick_params_list[i] => {}}.merge(h) }.to_yaml %>")
+ $yaml = inline_template("<%= (0..@valid_count.to_i-1).inject(Hash.new) { |h,i| {@brick_params_list[i] => (((i < @valid_brick_params_defaults.length) and @valid_brick_params_defaults[i].is_a?(Hash)) ? @valid_brick_params_defaults[i] : {})}.merge(h) }.to_yaml %>")
}
$hash = parseyaml($yaml)
diff --git a/puppet-gluster-documentation.pdf b/puppet-gluster-documentation.pdf
index 7ec3968..ba8ea10 100644
--- a/puppet-gluster-documentation.pdf
+++ b/puppet-gluster-documentation.pdf
Binary files differ