summaryrefslogtreecommitdiffstats
path: root/manifests
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2013-06-03 19:54:43 -0400
committerJames Shubin <james@shubin.ca>2013-06-03 19:54:43 -0400
commit2a65757ead328e87e2ae656d39040d5c96bc2f0d (patch)
treedc03e044baa50959d1ae3df1285d9fa6b5f50a69 /manifests
parent9aae259df87ab22b47185d9ff61d1d0020f33d2a (diff)
downloadpuppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.tar.gz
puppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.tar.xz
puppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.zip
Cleanup some small things.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/vardir.pp52
-rw-r--r--manifests/volume/property.pp9
-rw-r--r--manifests/volume/property/base.pp12
-rw-r--r--manifests/wrapper.pp12
4 files changed, 76 insertions, 9 deletions
diff --git a/manifests/vardir.pp b/manifests/vardir.pp
new file mode 100644
index 0000000..4caa692
--- /dev/null
+++ b/manifests/vardir.pp
@@ -0,0 +1,52 @@
+# 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::vardir { # module vardir snippet
+ if "${::puppet_vardirtmp}" == '' {
+ if "${::puppet_vardir}" == '' {
+ # here, we require that the puppetlabs fact exist!
+ fail('Fact: $puppet_vardir is missing!')
+ }
+ $tmp = sprintf("%s/tmp/", regsubst($::puppet_vardir, '\/$', ''))
+ # base directory where puppet modules can work and namespace in
+ file { "${tmp}":
+ ensure => directory, # make sure this is a directory
+ recurse => false, # don't recurse into directory
+ purge => true, # purge all unmanaged files
+ force => true, # also purge subdirs and links
+ owner => root,
+ group => nobody,
+ mode => 600,
+ backup => false, # don't backup to filebucket
+ #before => File["${module_vardir}"], # redundant
+ #require => Package['puppet'], # no puppet module seen
+ }
+ } else {
+ $tmp = sprintf("%s/", regsubst($::puppet_vardirtmp, '\/$', ''))
+ }
+ $module_vardir = sprintf("%s/gluster/", regsubst($tmp, '\/$', ''))
+ file { "${module_vardir}": # /var/lib/puppet/tmp/gluster/
+ ensure => directory, # make sure this is a directory
+ recurse => true, # recursively manage directory
+ purge => true, # purge all unmanaged files
+ force => true, # also purge subdirs and links
+ owner => root, group => nobody, mode => 600, backup => false,
+ require => File["${tmp}"], # File['/var/lib/puppet/tmp/']
+ }
+}
+
+# vim: ts=8
diff --git a/manifests/volume/property.pp b/manifests/volume/property.pp
index a441fb8..5ddcf7b 100644
--- a/manifests/volume/property.pp
+++ b/manifests/volume/property.pp
@@ -22,6 +22,9 @@ define gluster::volume::property(
$autotype = true # set to false to disable autotyping
) {
include gluster::volume::property::base
+ include gluster::vardir
+ #$vardir = $::gluster::vardir::module_vardir # with trailing slash
+ $vardir = regsubst($::gluster::vardir::module_vardir, '\/$', '')
$split = split($name, '#') # do some $name parsing
$volume = $split[0] # volume name
@@ -51,7 +54,7 @@ define gluster::volume::property(
$safe_value = shellquote($value) # TODO: is this the safe thing?
# if it's not a string and it's not the expected type, fail
- } elsif ( type($value) != $etype ) { # type() is from puppet-common
+ } elsif ( type($value) != $etype ) { # type() from puppetlabs-stdlib
fail("Gluster::Volume::Property[${key}] must be type: ${etype}.")
# convert to correct type
@@ -78,11 +81,11 @@ define gluster::volume::property(
# 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} | /var/lib/puppet/tmp/gluster/xml.py ${key}`\" = '${safe_value}'",
+ unless => "/usr/bin/test \"`/usr/sbin/gluster volume --xml info ${volume} | ${vardir}/xml.py ${key}`\" = '${safe_value}'",
logoutput => on_failure,
require => [
Gluster::Volume[$volume],
- File['/var/lib/puppet/tmp/gluster/xml.py'],
+ File["${vardir}/xml.py"],
],
}
}
diff --git a/manifests/volume/property/base.pp b/manifests/volume/property/base.pp
index 04c7ccc..4d5149d 100644
--- a/manifests/volume/property/base.pp
+++ b/manifests/volume/property/base.pp
@@ -16,18 +16,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class gluster::volume::property::base {
+ include gluster::vardir
+
package { 'python-lxml': # for parsing gluster xml output
ensure => present,
}
- file { '/var/lib/puppet/tmp/gluster/xml.py':
+ #$vardir = $::gluster::vardir::module_vardir # with trailing slash
+ $vardir = regsubst($::gluster::vardir::module_vardir, '\/$', '')
+
+ file { "${vardir}/xml.py":
source => 'puppet:///modules/gluster/xml.py',
owner => root,
group => nobody,
mode => 700, # u=rwx
backup => false, # don't backup to filebucket
ensure => present,
- require => Package['python-lxml'],
+ require => [
+ Package['python-lxml'],
+ File["${vardir}/"],
+ ],
}
}
diff --git a/manifests/wrapper.pp b/manifests/wrapper.pp
index 2bea8af..2b21993 100644
--- a/manifests/wrapper.pp
+++ b/manifests/wrapper.pp
@@ -57,7 +57,8 @@ class gluster::wrapper(
#$hosttree = inline_template('<%= nodetree.each_with_object({}) {|(x,y), h| h[x] = y.select{ |key,value| ["uuid"].include?(key) } }.to_yaml %>')
$hosttree = inline_template('<%= nodetree.inject({}) {|h, (x,y)| h[x] = y.select{ |key,value| ["uuid"].include?(key) }; h }.to_yaml %>')
# newhash = oldhash.inject({}) { |h,(k,v)| h[k] = some_operation(v); h } # XXX: does this form work ?
- create_resources('gluster::host', loadyaml($hosttree))
+ $yaml_host = parseyaml($hosttree)
+ create_resources('gluster::host', $yaml_host)
#
# build gluster::brick
@@ -78,7 +79,8 @@ class gluster::wrapper(
$bricktree = inline_template('<%= r = {}; nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v} }; r.to_yaml %>')
# this version removes any invalid keys from the brick specifications
#$bricktree = inline_template('<%= r = {}; nodetree.each {|x,y| y["bricks"].each {|k,v| r[x+":"+k] = v.select{ |key,value| ["dev", "labeltype", "fstype", "fsuuid", "..."].include?(key) } } }; r.to_yaml %>')
- create_resources('gluster::brick', loadyaml($bricktree))
+ $yaml_brick = parseyaml($bricktree)
+ create_resources('gluster::brick', $yaml_brick)
#
# build gluster::volume
@@ -112,7 +114,8 @@ class gluster::wrapper(
}
# loop through volumetree... if special defaults are missing, then add!
$volumetree_updated = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x] = y; volumetree_defaults.each {|k,v| h[k] = h.fetch(k, v)} }.to_yaml %>')
- create_resources('gluster::volume', loadyaml($volumetree_updated))
+ $yaml_volume = parseyaml($volumetree_updated)
+ create_resources('gluster::volume', $yaml_volume)
#
# build gluster::volume::property (auth.allow)
@@ -125,7 +128,8 @@ class gluster::wrapper(
#$simplewrongname = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = y.select{ |key,value| ["clients"].include?(key) } }.to_yaml %>')
$propertytree = inline_template('<%= volumetree.each_with_object({}) {|(x,y), h| h[x+"#auth.allow"] = { "value" => y.fetch("clients", []) } }.to_yaml %>')
- create_resources('gluster::volume::property', loadyaml($propertytree))
+ $yaml_volume_property = parseyaml($propertytree)
+ create_resources('gluster::volume::property', $yaml_volume_property)
}
# vim: ts=8