diff options
author | Thom May <thom@may.lt> | 2018-01-30 11:08:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 11:08:22 +0000 |
commit | c31361d0cb35807fddf189724e1b0fe99ea78acd (patch) | |
tree | 30c2b8ffd5c38d4a6d46b8abd3e702fc0360990f | |
parent | 3f768e7befa20d726ef7e643d87837810cf6c075 (diff) | |
parent | 4f394f02120882f41909e742d763ab382f88682e (diff) | |
download | chef-c31361d0cb35807fddf189724e1b0fe99ea78acd.tar.gz |
Merge pull request #6782 from cramaechi/CHEF-4959
Update /etc/fstab on FreeBSD #4959
-rw-r--r-- | lib/chef/provider/mount/mount.rb | 7 | ||||
-rw-r--r-- | spec/unit/provider/mount/mount_spec.rb | 22 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index c3b1cc0141..0be45e80da 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -146,6 +146,11 @@ class Chef end end + # Return appropriate default mount options according to the given os. + def default_mount_options + node[:os] == "linux" ? "defaults" : "rw" + end + def enable_fs if @current_resource.enabled && mount_options_unchanged? Chef::Log.debug("#{@new_resource} is already enabled - nothing to do") @@ -158,7 +163,7 @@ class Chef disable_fs end ::File.open("/etc/fstab", "a") do |fstab| - fstab.puts("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? "defaults" : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}") + 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}") Chef::Log.debug("#{@new_resource} is enabled at #{@new_resource.mount_point}") end end diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 20a4fd88dd..b61dc65800 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -374,6 +374,28 @@ describe Chef::Provider::Mount::Mount do end end + describe "default_mount_options" do + it "should return the correct default mount options for Linux" do + @provider.node.override[:os] = "linux" + expect(@provider.default_mount_options).to eq("defaults") + end + + it "should return the correct default mount options for AIX" do + @provider.node.override[:os] = "aix" + expect(@provider.default_mount_options).to eq("rw") + end + + it "should return the correct default mount options for Darwin" do + @provider.node.override[:os] = "darwin" + expect(@provider.default_mount_options).to eq("rw") + end + + it "should return the correct default mount options for FreeBSD" do + @provider.node.override[:os] = "freebsd" + expect(@provider.default_mount_options).to eq("rw") + end + end + describe "when enabling the fs" do it "should enable if enabled isn't true" do @current_resource.enabled(false) |