summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-03-09 18:28:47 +0000
committerThom May <thom@chef.io>2018-03-14 16:29:48 +0000
commit61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9 (patch)
treec83baedaba2f265ebc85a4be907ad2c0ea0c26a8 /lib/chef/provider
parentf1c97d18f68b01e8f82757bbb1111ca82d4fba99 (diff)
downloadchef-61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9.tar.gz
update mount to use properties and fix 6851
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/mount.rb10
-rw-r--r--lib/chef/provider/mount/mount.rb15
2 files changed, 17 insertions, 8 deletions
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb
index 4d0d273ea9..533dd2514b 100644
--- a/lib/chef/provider/mount.rb
+++ b/lib/chef/provider/mount.rb
@@ -83,7 +83,7 @@ class Chef
end
def action_enable
- unless current_resource.enabled && mount_options_unchanged?
+ unless current_resource.enabled && mount_options_unchanged? && device_unchanged?
converge_by("enable #{current_resource.device}") do
enable_fs
Chef::Log.info("#{new_resource} enabled")
@@ -120,6 +120,14 @@ class Chef
raise Chef::Exceptions::UnsupportedAction, "#{self} does not implement #mount_options_unchanged?"
end
+ # It's entirely plausible that a site might prefer UUIDs or labels, so
+ # we need to be able to update fstab to conform with their wishes
+ # without necessarily needing to remount the device.
+ # See #6851 for more.
+ def device_unchanged?
+ @current_resource.device == @new_resource.device
+ end
+
#
# NOTE: for the following methods, this superclass will already have checked if the filesystem is
# enabled and/or mounted and they will be called in converge_by blocks, so most defensive checking
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 0be45e80da..dd35a84186 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -57,12 +57,13 @@ class Chef
case line
when /^[#\s]/
next
- when /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
+ when /^(#{device_fstab_regex})\s+#{Regexp.escape(@new_resource.mount_point)}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
enabled = true
- @current_resource.fstype($1)
- @current_resource.options($2)
- @current_resource.dump($3.to_i)
- @current_resource.pass($4.to_i)
+ @current_resource.device($1)
+ @current_resource.fstype($2)
+ @current_resource.options($3)
+ @current_resource.dump($4.to_i)
+ @current_resource.pass($5.to_i)
Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/fstab")
next
when /^[\/\w]+\s+#{Regexp.escape(@new_resource.mount_point)}\s+/
@@ -152,7 +153,7 @@ class Chef
end
def enable_fs
- if @current_resource.enabled && mount_options_unchanged?
+ if @current_resource.enabled && mount_options_unchanged? && device_unchanged?
Chef::Log.debug("#{@new_resource} is already enabled - nothing to do")
return nil
end
@@ -258,7 +259,7 @@ class Chef
if @new_resource.device_type == :device
device_mount_regex
else
- device_fstab
+ Regexp.union(device_fstab, device_mount_regex)
end
end