summaryrefslogtreecommitdiffstats
path: root/manifests
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 /manifests
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.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/simple.pp56
1 files changed, 36 insertions, 20 deletions
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)