diff options
author | James Shubin <james@shubin.ca> | 2013-12-22 18:38:04 -0500 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2013-12-22 18:38:04 -0500 |
commit | ca290d42f9d97e4db3a85429a0374319fc4a4b91 (patch) | |
tree | 93f61598e40ee965b99ee0e1cbe1d3153bf971e4 | |
parent | 8ebe677878f9195e0cfe7d9512e8f466b3aab9e0 (diff) | |
download | puppet-gluster-ca290d42f9d97e4db3a85429a0374319fc4a4b91.tar.gz puppet-gluster-ca290d42f9d97e4db3a85429a0374319fc4a4b91.tar.xz puppet-gluster-ca290d42f9d97e4db3a85429a0374319fc4a4b91.zip |
Improved auto repo management and version selection.
Introduced a split between repo management and version choosing.
You can now:
* Choose a package version or leave it at the default (latest).
If you choose a package version it must include the release string.
eg: in foobar-3.2.1-42.el6 the release is 42.el6
This doesn't check to see if your version is valid!
* Choose whether you want a gluster repo added automatically.
If you did specify a version, it will pick the correct repo.
This doesn't check that the repo for your os/version exists!
-rw-r--r-- | manifests/repo.pp | 17 | ||||
-rw-r--r-- | manifests/server.pp | 33 | ||||
-rw-r--r-- | manifests/simple.pp | 2 |
3 files changed, 41 insertions, 11 deletions
diff --git a/manifests/repo.pp b/manifests/repo.pp index e9b53de..2c24593 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -29,13 +29,22 @@ class gluster::repo( # latest $base_v = "${base}LATEST/" } else { - if "${version}" =~ /^(\d+)\.(\d+)$/ { # x.y + notice("GlusterFS version: '${version}' was chosen.") + + # parse out the -release if it exists. example: 3.4.2-13.el6 + # \1 is the major/minor version, eg: 3.4.2 + # \2 is the release with a leading dash, eg: -13.el6 + # \3 is the first part of the release, eg: 13 + # \4 is the second part of the release, eg: el6 + $real_v = regsubst("${version}", '^([\d\.]*)(\-([\d]{1,})\.([a-zA-Z\d]{1,}))?$', '\1') + + if "${real_v}" =~ /^(\d+)\.(\d+)$/ { # x.y #$base_v = "${base}${1}.${2}/LATEST/" # same! - $base_v = "${base}${version}/LATEST/" + $base_v = "${base}${real_v}/LATEST/" - } elsif "${version}" =~ /^(\d+)\.(\d+)\.(\d+)$/ { # x.y.z + } elsif "${real_v}" =~ /^(\d+)\.(\d+)\.(\d+)$/ { # x.y.z #$base_v = "${base}${1}.${2}/${1}.${2}.${3}/" # same! - $base_v = "${base}${1}.${2}/${version}/" + $base_v = "${base}${1}.${2}/${real_v}/" } else { fail('The version string is invalid.') } diff --git a/manifests/server.pp b/manifests/server.pp index baea415..874702f 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -18,7 +18,8 @@ class gluster::server( $vip = '', # vip of the cluster (optional but recommended) $nfs = false, # TODO - $repo = true, # true/false/or pick a specific version (true) + $repo = true, # add a repo automatically? true or false + $version = '', # pick a specific version (defaults to latest) $shorewall = false, $zone = 'net', # TODO: allow a list of zones $ips = false, # an optional list of ip's for each in hosts[] @@ -26,19 +27,37 @@ class gluster::server( ) { $FW = '$FW' # make using $FW in shorewall easier + # $gluster_package_version is a fact; commonly set by vagrant + if "${version}" == '' and "${gluster_package_version}" == '' { + $valid_version = '' + } else { + if "${version}" != '' and "${gluster_package_version}" != '' { + warning('Requested GlusterFS version specified twice!') + if "${version}" != "${gluster_package_version}" { + fail('Requested GlusterFS version mismatch!') + } + $valid_version = "${version}" + } elsif "${version}" != '' { + $valid_version = "${version}" + } elsif "${gluster_package_version}" != '' { + $valid_version = "${gluster_package_version}" + } else { + fail('Programming error!') + } + } + # ensure these are from a gluster repo if $repo { - $version = $repo ? { - true => '', # latest - default => "${repo}", - } class { '::gluster::repo': - version => "${version}", + version => "${valid_version}", } } package { 'glusterfs-server': - ensure => present, + ensure => "${valid_version}" ? { + '' => present, + default => "${valid_version}", + }, require => $repo ? { false => undef, default => Class['::gluster::repo'], diff --git a/manifests/simple.pp b/manifests/simple.pp index dec6dc7..63bc914 100644 --- a/manifests/simple.pp +++ b/manifests/simple.pp @@ -22,6 +22,7 @@ class gluster::simple( $stripe = 1, # TODO: not fully implemented in puppet-gluster $vip = '', # strongly recommended $repo = true, + $version = '', $shorewall = true ) { include gluster::vardir @@ -60,6 +61,7 @@ class gluster::simple( class { '::gluster::server': vip => "${vip}", repo => $repo, + version => "${version}", #zone => 'net', # defaults to net shorewall => $shorewall, } |