summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-03-06 00:19:06 -0500
committerJames Shubin <james@shubin.ca>2014-03-16 22:38:47 -0400
commit12df64beeb2f2bf003c86ca39ddb368a53afafee (patch)
treec2398c8fa16f810d6845b0d4d749085cf2026f13
parent06454f4f4d61d9c77fe1155c3c9e7de70fbc43b8 (diff)
downloadpuppet-gluster-12df64beeb2f2bf003c86ca39ddb368a53afafee.tar.gz
puppet-gluster-12df64beeb2f2bf003c86ca39ddb368a53afafee.tar.xz
puppet-gluster-12df64beeb2f2bf003c86ca39ddb368a53afafee.zip
Allow specifying brick device and other parameters in gluster::simple.
This patch adds support to specify the brick device values as a hash. It also allows for separate defaults that apply to the whole cluster.
-rw-r--r--examples/gluster-simple-physical-example.pp40
-rw-r--r--manifests/brick.pp5
-rw-r--r--manifests/simple.pp63
3 files changed, 104 insertions, 4 deletions
diff --git a/examples/gluster-simple-physical-example.pp b/examples/gluster-simple-physical-example.pp
new file mode 100644
index 0000000..377958b
--- /dev/null
+++ b/examples/gluster-simple-physical-example.pp
@@ -0,0 +1,40 @@
+#
+# simple gluster setup for physical provisioning.
+# (yeah, that's it-- for iron!)
+#
+
+node /^annex\d+$/ { # annex{1,2,..N}
+
+ class { '::gluster::simple':
+ # by allowing you to enumerate these things here in this class,
+ # you're able to specify all of these from a provisioning tool.
+ # this is useful in a tool like foreman which only lets you set
+ # class variables, and doesn't let you define individual types!
+ replica => 2,
+ vip = '192.168.1.42',
+ vrrp = true,
+ # NOTE: this example will show you different possibilities, but
+ # it is probably not sane to define your devices in a mixed way
+ brick_params => {
+ 'fqdn1.example.com' => [
+ {dev => '/dev/disk/by-uuid/01234567-89ab-cdef-0123-456789abcdef'},
+ {dev => '/dev/sde', partition => false},
+ ],
+ 'fqdn2.example.com' => [
+ {dev => '/dev/disk/by-path/pci-0000:02:00.0-scsi-0:1:0:0', raid_su => 256, raid_sw => 10}
+ {dev => '/dev/disk/by-id/wwn-0x600508e0000000002b012b744715743a', lvm => true},
+ ],
+ #'fqdnN.example.com' => [...],
+ },
+
+ # these will get used by every brick, even if only specified by
+ # the count variable... keep in mind that without the $dev var,
+ # some of these parameters aren't used by the filesystem brick.
+ brick_param_defaults => {
+ lvm => false,
+ xfs_inode64 => true,
+ force => true,
+ },
+ }
+}
+
diff --git a/manifests/brick.pp b/manifests/brick.pp
index 14d9abb..3957e0c 100644
--- a/manifests/brick.pp
+++ b/manifests/brick.pp
@@ -35,7 +35,8 @@ define gluster::brick(
$xfs_inode64 = false,
$xfs_nobarrier = false,
$force = false, # if true, this will overwrite any xfs fs it sees, useful for rebuilding gluster and wiping data. NOTE: there are other safeties in place to stop this.
- $areyousure = false # do you allow puppet to do dangerous things ?
+ $areyousure = false, # do you allow puppet to do dangerous things ?
+ $comment = ''
) {
include gluster::brick::base
include gluster::vardir
@@ -136,7 +137,7 @@ define gluster::brick(
$dev2 = "/dev/${lvm_vgname}/${lvm_lvname}"
} else {
- $dev2 = "${dev1}", # pass through, because not using lvm
+ $dev2 = "${dev1}" # pass through, because not using lvm
}
#
diff --git a/manifests/simple.pp b/manifests/simple.pp
index ff7d49c..8175731 100644
--- a/manifests/simple.pp
+++ b/manifests/simple.pp
@@ -25,6 +25,24 @@ class gluster::simple(
$password = '', # global vrrp password to use
$version = '',
$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,
+ # }
$baseport = '', # specify base port option as used in glusterd.vol file
$rpcauthallowinsecure = false, # needed in some setups in glusterd.vol
$shorewall = true
@@ -51,6 +69,15 @@ class gluster::simple(
$valid_path = sprintf("%s/", regsubst($chosen_path, '\/$', ''))
+ validate_hash($brick_param_defaults)
+ # in someone explicitly added this value, then don't overwrite it...
+ if has_key($brick_param_defaults, 'areyousure') {
+ $valid_brick_param_defaults = $brick_param_defaults
+ } else {
+ $areyousure = {areyousure => true}
+ $valid_brick_param_defaults = merge($brick_param_defaults, $areyousure)
+ }
+
notify { 'gluster::simple':
message => 'You are using gluster::simple !',
}
@@ -82,10 +109,42 @@ class gluster::simple(
}
Gluster::Host <<||>>
- @@gluster::brick { "${::fqdn}:${valid_path}":
- areyousure => true,
+ # the idea here is to build a list of bricks from a list of parameters,
+ # with each element in the list, corresponding to a hash of key=>values
+ # each element in the list is a different brick. the key for the master
+ # hash is the fqdn of the host that those bricks correspond to. you can
+ # also specify a list of defaults for when you have common brick values
+ # such as $xfs_inode64=>true, or raid_* if your cluster is symmetrical!
+ # if you set the $count variable, then that brick count will be forced.
+ validate_re("${count}", '^\d+$') # ensure this is a positive int
+ if has_key($brick_params, "${::fqdn}") {
+ # here some wizardry happens...
+ $valid_count = $count ? {
+ 0 => inline_template('<%= brick_params_list.length %>'),
+ default => $count,
+ }
+ $brick_params_list = $brick_params["${::fqdn}"]
+ 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 %>")
+ } else {
+ # here we base our brick list on the $count variable alone...
+ $valid_count = $count ? {
+ 0 => 1, # 0 means undefined, so use the default
+ default => $count,
+ }
+ $brick_params_list = $valid_count ? {
+ # TODO: should we use the same pattern for 1 or many ?
+ 1 => ["${::fqdn}:${valid_path}"],
+ default => split(inline_template("<%= (1..${valid_count}).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 %>")
}
+ $hash = parseyaml($yaml)
+ create_resources('@@gluster::brick', $hash, $valid_brick_param_defaults)
+ #@@gluster::brick { "${::fqdn}:${valid_path}":
+ # areyousure => true,
+ #}
Gluster::Brick <<||>>
gluster::volume { $volume: