summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Schulte <stefan.schulte@taunusstein.net>2011-01-23 14:21:45 +0100
committerStefan Schulte <stefan.schulte@taunusstein.net>2011-01-25 21:23:35 +0100
commit9f4060860a3e8247d95696ffb9e0aaf4acdd539d (patch)
treec37ad13b2418c393bc353e47dd8ea96d915508d0
parentfd111f26f17b3dbdd0de310d0a4b43877eef7e14 (diff)
downloadpuppet-9f4060860a3e8247d95696ffb9e0aaf4acdd539d.tar.gz
puppet-9f4060860a3e8247d95696ffb9e0aaf4acdd539d.tar.xz
puppet-9f4060860a3e8247d95696ffb9e0aaf4acdd539d.zip
(#4914) Update property blocks
The action for a specific ensure state depends on the actual state so we cannot use the default behaviour. The following transitions are now supported (with ghost = mounted but not present in fstab): * 4 Is-states : absent, mounted, unmounted, ghost * 4 Should-states: absent, mounted, present, unmounted * from ghost to present -> create * from absent to present -> create * from ghost to unmounted -> create, umount * from mounted to unmounted -> umount * from absent to unmounted -> create * from ghost to absent -> umount (may fail on certain OS) * from mounted to absent -> umount, destroy * from unmounted to absent -> destroy * from ghost to mounted -> create * from absent to mounted -> create, mount * from unmounted to mounted -> mount Every other combination is treatet insync
-rwxr-xr-xlib/puppet/type/mount.rb55
1 files changed, 35 insertions, 20 deletions
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb
index d048c90f1..bcd24a1db 100755
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@ -21,6 +21,11 @@ module Puppet
fstab and mount it. Set to `present` to add to fstab but not change
mount/unmount status"
+ # IS -> SHOULD In Sync Action
+ # ghost -> present NO create
+ # absent -> present NO create
+ # (mounted -> present YES)
+ # (unmounted -> present YES)
newvalue(:defined) do
provider.create
return :mount_created
@@ -28,27 +33,48 @@ module Puppet
aliasvalue :present, :defined
+ # IS -> SHOULD In Sync Action
+ # ghost -> unmounted NO create, unmount
+ # absent -> unmounted NO create
+ # mounted -> unmounted NO unmount
newvalue(:unmounted) do
- if provider.mounted?
- syncothers
+ case self.retrieve
+ when :ghost # (not in fstab but mounted)
+ provider.create
+ @resource.flush
provider.unmount
return :mount_unmounted
- else
+ when nil, :absent # (not in fstab and not mounted)
provider.create
return :mount_created
+ when :mounted # (in fstab and mounted)
+ provider.unmount
+ syncothers # I guess it's more likely that the mount was originally mounted with
+ # the wrong attributes so I sync AFTER the umount
+ return :mount_unmounted
+ else
+ raise Puppet::Error, "Unexpected change from #{current_value} to unmounted}"
end
end
+ # IS -> SHOULD In Sync Action
+ # ghost -> absent NO unmount
+ # mounted -> absent NO provider.destroy AND unmount
+ # unmounted -> absent NO provider.destroy
newvalue(:absent, :event => :mount_deleted) do
+ current_value = self.retrieve
provider.unmount if provider.mounted?
-
- provider.destroy
+ provider.destroy unless current_value == :ghost
end
+ # IS -> SHOULD In Sync Action
+ # ghost -> mounted NO provider.create
+ # absent -> mounted NO provider.create AND mount
+ # unmounted -> mounted NO mount
newvalue(:mounted, :event => :mount_mounted) do
# Create the mount point if it does not already exist.
current_value = self.retrieve
- provider.create if current_value.nil? or current_value == :absent
+ provider.create if [nil, :absent, :ghost].include?(current_value)
syncothers
@@ -56,27 +82,16 @@ module Puppet
provider.mount unless provider.mounted?
end
+ # insync: mounted -> present
+ # unmounted -> present
def insync?(is)
- if should == :defined and is != :absent
+ if should == :defined and [:mounted,:unmounted].include?(is)
true
else
super
end
end
- def retrieve
- # We need to special case :mounted; if we're absent, we still
- # want
- curval = super()
- if curval == :absent
- return :absent
- elsif provider.mounted?
- return :mounted
- else
- return :unmounted
- end
- end
-
def syncothers
# We have to flush any changes to disk.
currentvalues = @resource.retrieve_resource