diff options
author | James Shubin <james@shubin.ca> | 2013-06-03 19:54:43 -0400 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2013-06-03 19:54:43 -0400 |
commit | 2a65757ead328e87e2ae656d39040d5c96bc2f0d (patch) | |
tree | dc03e044baa50959d1ae3df1285d9fa6b5f50a69 | |
parent | 9aae259df87ab22b47185d9ff61d1d0020f33d2a (diff) | |
download | puppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.tar.gz puppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.tar.xz puppet-gluster-2a65757ead328e87e2ae656d39040d5c96bc2f0d.zip |
Cleanup some small things.
-rw-r--r-- | COPYRIGHT | 4 | ||||
-rw-r--r-- | INSTALL | 18 | ||||
-rw-r--r-- | README | 26 | ||||
-rw-r--r-- | manifests/vardir.pp | 52 | ||||
-rw-r--r-- | manifests/volume/property.pp | 9 | ||||
-rw-r--r-- | manifests/volume/property/base.pp | 12 | ||||
-rw-r--r-- | manifests/wrapper.pp | 12 |
7 files changed, 114 insertions, 19 deletions
@@ -1,5 +1,5 @@ -Copyright (C) 2010-2012 James Shubin -# Written by James Shubin <james@shubin.ca> +Copyright (C) 2012-2013+ James Shubin +Written by James Shubin <james@shubin.ca> This puppet module is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -0,0 +1,18 @@ +To install this puppet module, copy this folder to your puppet modulepath. + +You can usually find out where this is by running: + +$ puppet config print modulepath + +on your puppetmaster. In my case, this contains the directory: + +/etc/puppet/modules/ + +I keep all of my puppet modules in git managed directories named: + +puppet-<modulename> + +You must remove the 'puppet-' prefix from the directory name for it to work! + +Happy hacking! + @@ -1,13 +1,23 @@ -puppet-gluster, by James Shubin <james@shubin.ca>, https://ttboj.wordpress.com/ +This is puppet-gluster a puppet module for gluster. -WARNING: This module is in development phase, and things might change drastically. You've been warned. Sorry about any ugliness that is present at the moment. +Please read the INSTALL file for instructions on getting this installed. +Look in the examples/ folder for usage. If none exist, please contribute one! +This code may be a work in progress. The interfaces may change without notice. +Patches are welcome, but please be patient. They are best received by email. +Please ping me if you have big changes in mind, before you write a giant patch. -DEPENDENCIES: This module (optionally) depends on my unreleased puppet-shorewall module. +Module specific notes: +* All the participating nodes, need to have an identical puppet-gluster config. +* There is an experimental gluster::wrapper class, for easier deployment. +* You can use less of the available resources, if you only want to manage some. -PATCHES/DISCUSSION: Initially both welcome by email, although I'd prefer you give me a heads up first so that we're working in the same direction. +Dependencies: +* puppetlabs-stdlib (required) +* my puppet-common module (optional) +* my puppet-shorewall module (optional) +* my puppet-puppet module (optional) -USAGE: -Put these two folders in your $PUPPET_MODULE_DIR/gluster/ -Configure your nodes... (All server nodes should have identical puppet config) -Profit!!! + +Happy hacking, +James Shubin <james@shubin.ca>, https://ttboj.wordpress.com/ 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 |