summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantima-gupta <agupta@msystechnologies.com>2020-11-13 01:22:10 -0800
committerantima-gupta <agupta@msystechnologies.com>2020-11-13 01:22:10 -0800
commitf390e98e5dfed55a3c9a8315a6da2f426e5c6640 (patch)
treeaa82435e19f826c09a7945aa514e6ea320064507
parent131729775678dc113d4c29a7db3b00f3135e8ba4 (diff)
downloadchef-f390e98e5dfed55a3c9a8315a6da2f426e5c6640.tar.gz
Updated edit_fstab method as per review comment.
Signed-off-by: antima-gupta <agupta@msystechnologies.com>
-rw-r--r--lib/chef/provider/mount/mount.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 83a2061d3d..71cecb47aa 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -166,7 +166,7 @@ class Chef
# The current options don't match what we have, so
# update the last matching entry with current option
# and order will remain the same.
- edit_fstab(:update)
+ edit_fstab
else
::File.open("/etc/fstab", "a") do |fstab|
fstab.puts("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? default_mount_options : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
@@ -176,7 +176,7 @@ class Chef
end
def disable_fs
- edit_fstab(:remove)
+ edit_fstab(remove: true)
end
def network_device?
@@ -248,7 +248,7 @@ class Chef
end
# It will update or delete the entry from fstab.
- def edit_fstab(action)
+ def edit_fstab(remove: false)
if @current_resource.enabled
contents = []
@@ -256,11 +256,11 @@ class Chef
::File.readlines("/etc/fstab").reverse_each do |line|
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s/
found = true
- if action == :update
- logger.trace("#{@new_resource} is updated with new content in fstab")
- contents << ("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? default_mount_options : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
- else
+ if remove
logger.trace("#{@new_resource} is removed from fstab")
+ else
+ contents << ("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? default_mount_options : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
+ logger.trace("#{@new_resource} is updated with new content in fstab")
end
next
else