summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorantima-gupta <agupta@msystechnologies.com>2020-11-10 04:28:35 -0800
committerantima-gupta <agupta@msystechnologies.com>2020-11-11 03:45:31 -0800
commit2ca48d25ddfe4ccea309271a7831db971c7a603e (patch)
tree31f90f1c0a78d62e9a33f04cdb7761732a9618d4 /lib/chef
parentf583db2d28bb78622d55e6c4b1a26a64b55b1e41 (diff)
downloadchef-2ca48d25ddfe4ccea309271a7831db971c7a603e.tar.gz
Fixes for CIFS mount not idempotent issue.
Added spec for network device found as mounted. Removed '/' from end of the device value. Signed-off-by: antima-gupta <agupta@msystechnologies.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/provider/mount.rb8
-rw-r--r--lib/chef/provider/mount/linux.rb4
-rw-r--r--lib/chef/provider/mount/mount.rb3
3 files changed, 11 insertions, 4 deletions
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb
index 64c7bc3f29..e4592a810d 100644
--- a/lib/chef/provider/mount.rb
+++ b/lib/chef/provider/mount.rb
@@ -175,13 +175,15 @@ class Chef
# Returns the new_resource device as per device_type
def device_fstab
+ # Removed "/" from the end of str, because it was causing idempotency issues
+ device = @new_resource.device.chomp("/")
case @new_resource.device_type
when :device
- @new_resource.device
+ device
when :label
- "LABEL=#{@new_resource.device}"
+ "LABEL=#{device}"
when :uuid
- "UUID=#{@new_resource.device}"
+ "UUID=#{device}"
end
end
end
diff --git a/lib/chef/provider/mount/linux.rb b/lib/chef/provider/mount/linux.rb
index 3199024f1b..bd1844e717 100644
--- a/lib/chef/provider/mount/linux.rb
+++ b/lib/chef/provider/mount/linux.rb
@@ -53,6 +53,10 @@ class Chef
when %r{\A#{Regexp.escape(real_mount_point)}\s+([/\w])+\[#{device_mount_regex}\]\s}
mounted = true
logger.trace("Bind device #{device_logstring} mounted as #{real_mount_point}")
+ # Permalink for network device mounted to an existing mount point: https://rubular.com/r/HicK63SqchPLvk
+ when %r{\A#{Regexp.escape(real_mount_point)}\s+#{device_mount_regex}\[([\/\w])+\]\s}
+ mounted = true
+ logger.trace("Network device #{device_logstring} mounted as #{real_mount_point}")
end
end
@current_resource.mounted(mounted)
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index f6a7519c06..e065ce09e5 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -223,7 +223,8 @@ class Chef
@real_device = device_line.chomp unless device_line.nil?
end
end
- @real_device
+ # Removed "/" from the end of str, because it was causing idempotency issue.
+ @real_device.chomp("/")
end
def device_logstring