summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-07-10 20:06:41 -0400
committerJames Shubin <james@shubin.ca>2014-07-10 20:06:41 -0400
commit8da4002f83e6505c7c09042df1c10cb1e290c7c7 (patch)
tree87c1b6bdf582aae8d91d3b5c78c8ef741693c740
parentcd182e0ef68c9ee0f5701b436050de7538ab6ff1 (diff)
downloadpuppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.tar.gz
puppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.tar.xz
puppet-gluster-8da4002f83e6505c7c09042df1c10cb1e290c7c7.zip
Ensure that UUID directory is actually managed.
This isn't necessary, but is more correct. I realized how I could do this, and have now implemented it.
-rw-r--r--lib/facter/gluster_uuid.rb19
-rw-r--r--manifests/host.pp25
2 files changed, 29 insertions, 15 deletions
diff --git a/lib/facter/gluster_uuid.rb b/lib/facter/gluster_uuid.rb
index ed0bf70..fa99a40 100644
--- a/lib/facter/gluster_uuid.rb
+++ b/lib/facter/gluster_uuid.rb
@@ -63,12 +63,25 @@ end
# generate uuid and parent directory if they don't already exist...
if not(module_vardir.nil?) and File.directory?(module_vardir)
- if not File.directory?(uuiddir)
- Dir::mkdir(uuiddir)
+
+ create = false
+ if File.directory?(uuiddir)
+
+ if File.exist?(uuidfile)
+ test = File.open(uuidfile, 'r').read.strip.downcase # read into str
+ # skip over uuid's of the wrong length or that don't match (security!!)
+ if test.length == 36 and regexp.match(test)
+ create = false
+ else
+ create = true
+ end
+ else
+ create = true
+ end
end
# create a uuid and store it in our vardir if it doesn't already exist!
- if File.directory?(uuiddir) and (not File.exist?(uuidfile))
+ if create
result = system("/usr/bin/uuidgen > '" + uuidfile + "'")
if not(result)
# TODO: print warning
diff --git a/manifests/host.pp b/manifests/host.pp
index 91a0548..7f6efed 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -60,9 +60,9 @@ define gluster::host(
# don't purge the uuid file generated within
file { "${vardir}/uuid/":
ensure => directory, # make sure this is a directory
- recurse => false, # don't recurse into directory
- purge => false, # don't purge unmanaged files
- force => false, # don't purge subdirs and links
+ recurse => true, # recurse into directory
+ purge => true, # purge unmanaged files
+ force => true, # purge subdirs and links
require => File["${vardir}/"],
}
@@ -70,15 +70,16 @@ define gluster::host(
# sticks if we ever go back to using automatic uuids. this is
# useful if a user wants to initially import uuids by picking
# them manually, and then letting puppet take over afterwards
- if "${uuid}" != '' {
- file { "${vardir}/uuid/uuid":
- content => "${uuid}\n",
- owner => root,
- group => root,
- mode => 600, # might as well...
- ensure => present,
- require => File["${vardir}/uuid/"],
- }
+ file { "${vardir}/uuid/uuid":
+ content => "${uuid}" ? {
+ '' => undef,
+ default => "${uuid}\n",
+ },
+ owner => root,
+ group => root,
+ mode => 600, # might as well...
+ ensure => present,
+ require => File["${vardir}/uuid/"],
}
$valid_uuid = "${uuid}" ? {