summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2013-12-17 21:35:41 -0500
committerJames Shubin <james@shubin.ca>2013-12-17 21:35:41 -0500
commit562da97b30ef55d8dca06dc9a920085e03d9fd56 (patch)
tree315865b5dafd7f25fa92e414b80517f037e5a2da
parent7b96488e80a78711539ac814e09892f6fd4afb0f (diff)
downloadpuppet-gluster-562da97b30ef55d8dca06dc9a920085e03d9fd56.tar.gz
puppet-gluster-562da97b30ef55d8dca06dc9a920085e03d9fd56.tar.xz
puppet-gluster-562da97b30ef55d8dca06dc9a920085e03d9fd56.zip
Automatically add yum repository.
Support for other operating systems will have to come later, even if this needs to be refactored. For now, CentOS/RHEL are automatic.
-rw-r--r--manifests/repo.pp99
-rw-r--r--manifests/server.pp17
-rw-r--r--manifests/simple.pp2
3 files changed, 117 insertions, 1 deletions
diff --git a/manifests/repo.pp b/manifests/repo.pp
new file mode 100644
index 0000000..e9b53de
--- /dev/null
+++ b/manifests/repo.pp
@@ -0,0 +1,99 @@
+# 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::repo(
+ # if you specify 'x.y', it will find the latest x.y.*
+ # if you specify 'x.y.z', it will stick to that version
+ # anything omitted is taken to mean "latest"
+ # if you leave this blank, we assume you want the latest version...
+ $version = ''
+) {
+ # XXX: this should be https !
+ $base = 'http://download.gluster.org/pub/gluster/glusterfs/'
+
+ if "${version}" == '' {
+ # latest
+ $base_v = "${base}LATEST/"
+ } else {
+ if "${version}" =~ /^(\d+)\.(\d+)$/ { # x.y
+ #$base_v = "${base}${1}.${2}/LATEST/" # same!
+ $base_v = "${base}${version}/LATEST/"
+
+ } elsif "${version}" =~ /^(\d+)\.(\d+)\.(\d+)$/ { # x.y.z
+ #$base_v = "${base}${1}.${2}/${1}.${2}.${3}/" # same!
+ $base_v = "${base}${1}.${2}/${version}/"
+ } else {
+ fail('The version string is invalid.')
+ }
+ }
+
+ case $operatingsystem {
+ 'CentOS': {
+ $base_os = "${base_v}CentOS/"
+ }
+ 'RedHat': {
+ $base_os = "${base_v}RHEL/"
+ }
+ #'Debian', 'Ubuntu': {
+ #}
+ default: {
+ fail("Operating system: '${operatingsystem}' not yet supported.")
+ }
+ }
+
+ $arch = "${architecture}" ? {
+ 'x86_64' => 'x86_64',
+ 'i386' => 'i386',
+ 'i486' => 'i386',
+ 'i586' => 'i386',
+ 'i686' => 'i386',
+ default => '',
+ }
+ if "${arch}" == '' {
+ fail("Architecture: '${architecture}' not yet supported.")
+ }
+
+ $base_arch = "${base_os}/epel-${operatingsystemrelease}/"
+
+ $gpgkey = "${base_os}pub.key"
+
+ include ::yum
+
+ #yum::repos::repo { "gluster-${arch}":
+ yum::repos::repo { 'gluster':
+ baseurl => "${base_arch}/${arch}/",
+ enabled => true,
+ gpgcheck => true,
+ # XXX: this should not be an http:// link, it should be a file!
+ # XXX: it's not even https! how can you even prevent a mitm...!
+ gpgkeys => ["${gpgkey}"],
+ ensure => present,
+ }
+
+ # TODO: technically, i don't think this is needed yet...
+ #yum::repos::repo { 'gluster-noarch':
+ # baseurl => "${base_arch}/noarch/",
+ # enabled => true,
+ # gpgcheck => true,
+ # # XXX: this should not be an http:// link, it should be a file!
+ # # XXX: it's not even https! how can you even prevent a mitm...!
+ # gpgkeys => ["${gpgkey}"],
+ # ensure => present,
+ #}
+}
+
+# vim: ts=8
diff --git a/manifests/server.pp b/manifests/server.pp
index 4215b08..baea415 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -18,6 +18,7 @@
class gluster::server(
$vip = '', # vip of the cluster (optional but recommended)
$nfs = false, # TODO
+ $repo = true, # true/false/or pick a specific version (true)
$shorewall = false,
$zone = 'net', # TODO: allow a list of zones
$ips = false, # an optional list of ip's for each in hosts[]
@@ -25,9 +26,23 @@ class gluster::server(
) {
$FW = '$FW' # make using $FW in shorewall easier
- # TODO: ensure these are from our 'gluster' repo
+ # ensure these are from a gluster repo
+ if $repo {
+ $version = $repo ? {
+ true => '', # latest
+ default => "${repo}",
+ }
+ class { '::gluster::repo':
+ version => "${version}",
+ }
+ }
+
package { 'glusterfs-server':
ensure => present,
+ require => $repo ? {
+ false => undef,
+ default => Class['::gluster::repo'],
+ },
}
# NOTE: not that we necessarily manage anything in here at the moment...
diff --git a/manifests/simple.pp b/manifests/simple.pp
index edd80ac..91847b4 100644
--- a/manifests/simple.pp
+++ b/manifests/simple.pp
@@ -21,6 +21,7 @@ class gluster::simple(
$replica = 1,
$stripe = 1, # TODO: not fully implemented in puppet-gluster
$vip = '', # strongly recommended
+ $repo = true,
$shorewall = true
) {
include gluster::vardir
@@ -58,6 +59,7 @@ class gluster::simple(
class { '::gluster::server':
vip => "${vip}",
+ repo => $repo,
#zone => 'net', # defaults to net
shorewall => $shorewall,
}