summaryrefslogtreecommitdiffstats
path: root/manifests
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2012-07-27 19:55:20 -0400
committerJames Shubin <james@shubin.ca>2012-07-27 19:55:20 -0400
commitab471b49d7f8740177b399f3146c57668a5509b1 (patch)
treef696daed6794d8f648429b9b9d8a801b5a325e76 /manifests
parent00c004343a0d40ec3c12ab0285dac6eb45533732 (diff)
downloadpuppet-gluster-ab471b49d7f8740177b399f3146c57668a5509b1.tar.gz
puppet-gluster-ab471b49d7f8740177b399f3146c57668a5509b1.tar.xz
puppet-gluster-ab471b49d7f8740177b399f3146c57668a5509b1.zip
Set volume properties.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/volume/property.pp49
-rw-r--r--manifests/volume/property/base.pp34
2 files changed, 83 insertions, 0 deletions
diff --git a/manifests/volume/property.pp b/manifests/volume/property.pp
new file mode 100644
index 0000000..f9131df
--- /dev/null
+++ b/manifests/volume/property.pp
@@ -0,0 +1,49 @@
+# Simple? gluster module by James
+# Copyright (C) 2010-2012 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/>.
+
+# NOTE: thanks to Joe Julian for: http://community.gluster.org/q/what-is-the-command-that-someone-can-run-to-get-the-value-of-a-given-property/
+
+define gluster::volume::property(
+ $value
+) {
+ include gluster::volume::property::base
+
+ $split = split($name, '#') # do some $name parsing
+ $volume = $split[0] # volume name
+ $key = $split[1] # key name
+
+ if ! ( "${volume}#${key}" == "${name}" ) {
+ fail('The property $name must match a $volume#$key pattern.')
+ }
+
+ $safe_value = shellquote($value) # TODO: is this the safe thing?
+
+ # volume set <VOLNAME> <KEY> <VALUE>
+ # set a volume property only if value doesn't match what is available
+ # FIXME: check that the value we're setting isn't the default
+ # FIXME: you can check defaults with... gluster volume set help | ...
+ exec { "/usr/sbin/gluster volume set ${volume} ${key} ${safe_value}":
+ unless => "/usr/bin/test \"`/usr/sbin/gluster volume --xml info ${volume} | ./xml.py ${key}`\" = '${safe_value}'",
+ logoutput => on_failure,
+ require => [
+ Gluster::Volume[$volume],
+ File['/var/lib/puppet/tmp/gluster/xml.py'],
+ ],
+ }
+}
+
+# vim: ts=8
diff --git a/manifests/volume/property/base.pp b/manifests/volume/property/base.pp
new file mode 100644
index 0000000..1f57895
--- /dev/null
+++ b/manifests/volume/property/base.pp
@@ -0,0 +1,34 @@
+# Simple? gluster module by James
+# Copyright (C) 2010-2012 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::volume::property::base {
+ package { 'python-lxml': # for parsing gluster xml output
+ ensure => present,
+ }
+
+ file { '/var/lib/puppet/tmp/gluster/xml.py':
+ source => 'puppet:///files/gluster/xml.py',
+ owner => root,
+ group => nobody,
+ mode => 700, # u=rwx
+ backup => false, # don't backup to filebucket
+ ensure => present,
+ require => Package['python-lxml'],
+ }
+}
+
+# vim: ts=8