diff options
-rw-r--r-- | lib/chef/provider/mount/aix.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/mount/solaris.rb | 27 | ||||
-rw-r--r-- | lib/chef/resource/mount.rb | 9 | ||||
-rw-r--r-- | spec/unit/provider/mount/solaris_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 41 |
5 files changed, 22 insertions, 61 deletions
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb index 240b71f747..4b60a4295d 100644 --- a/lib/chef/provider/mount/aix.rb +++ b/lib/chef/provider/mount/aix.rb @@ -28,7 +28,7 @@ class Chef super # options and fstype are set to "defaults" and "auto" respectively in the Mount Resource class. These options are not valid for AIX, override them. if @new_resource.options[0] == "defaults" - @new_resource.options.clear + @new_resource.options([]) end if @new_resource.fstype == "auto" @new_resource.send(:clear_fstype) diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb index a5a7a327cb..f59a2d2c6a 100644 --- a/lib/chef/provider/mount/solaris.rb +++ b/lib/chef/provider/mount/solaris.rb @@ -121,8 +121,8 @@ class Chef end def mount_options_unchanged? - new_options = options_remove_noauto(options) - current_options = options_remove_noauto(current_resource.nil? ? nil : current_resource.options) + new_options = native_options(options) + current_options = native_options(current_resource.nil? ? nil : current_resource.options) current_resource.fsck_device == fsck_device && current_resource.fstype == fstype && @@ -168,7 +168,8 @@ class Chef def read_vfstab_status # Check to see if there is an entry in /etc/vfstab. Last entry for a volume wins. enabled = false - fstype = options = pass = nil + pass = false + fstype = options = nil ::File.foreach(VFSTAB) do |line| case line when /^[#\s]/ @@ -220,11 +221,7 @@ class Chef end def vfstab_entry - actual_options = unless options.nil? - tempops = options.dup - tempops.delete("noauto") - tempops - end + actual_options = native_options(options) autostr = mount_at_boot? ? "yes" : "no" passstr = pass == 0 ? "-" : pass optstr = (actual_options.nil? || actual_options.empty?) ? "-" : actual_options.join(",") @@ -251,11 +248,15 @@ class Chef contents << vfstab_entry end - def options_remove_noauto(temp_options) - new_options = [] - new_options += temp_options.nil? ? [] : temp_options - new_options.delete("noauto") - new_options + def native_options(temp_options) + if temp_options == %w{defaults} + ["-"] + else + new_options = [] + new_options += temp_options.nil? ? [] : temp_options.dup + new_options.delete("noauto") + new_options + end end def device_regex diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index 119363aea7..dffb96cb53 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -28,8 +28,9 @@ class Chef allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable # this is a poor API please do not re-use this pattern - property :supports, Hash, default: lazy { { remount: false } }, - coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x } + property :supports, Hash, + default: lazy { { remount: false } }, + coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x } property :password, String, sensitive: true @@ -42,9 +43,9 @@ class Chef equal_to: RUBY_PLATFORM =~ /solaris/i ? %i{ device } : %i{ device label uuid } property :fsck_device, String, default: "-" - property :fstype, String, default: "auto" + property :fstype, [String, nil], default: "auto" - property :options, [Array, String], + property :options, [Array, String, nil], coerce: proc { |arg| arg.kind_of?(String) ? arg.split(",") : arg }, default: %w{defaults} diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 264c8b9b36..2ec9feaf3b 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -538,7 +538,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "after the mount's state has been discovered" do describe "mount_fs" do it "should mount the filesystem" do - expect(provider).to receive(:shell_out!).with("mount -F #{fstype} -o defaults #{device} #{mountpoint}") + expect(provider).to receive(:shell_out!).with("mount -F #{fstype} #{device} #{mountpoint}") provider.mount_fs() end @@ -600,7 +600,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "in the typical case" do let(:other_mount) { "/dev/dsk/c0t2d0s0 /dev/rdsk/c0t2d0s0 / ufs 2 yes -" } - let(:this_mount) { "/dev/dsk/c0t2d0s7\t/dev/rdsk/c0t2d0s7\t/mnt/foo\tufs\t2\tyes\tdefaults\n" } + let(:this_mount) { "/dev/dsk/c0t2d0s7\t/dev/rdsk/c0t2d0s7\t/mnt/foo\tufs\t2\tyes\t-\n" } let(:vfstab_file_contents) { [other_mount].join("\n") } diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 2d0dc6d91e..2fdad43f3f 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -168,45 +168,4 @@ describe Chef::Resource::Mount do resource.domain("TEST_DOMAIN") expect(resource.domain).to eq("TEST_DOMAIN") end - - describe "when it has mount point, device type, and fstype" do - before do - resource.device("charmander") - resource.mount_point("123.456") - resource.device_type(:device) - resource.fstype("ranked") - end - - it "describes its state" do - state = resource.state_for_resource_reporter - expect(state[:mount_point]).to eq("123.456") - expect(state[:device_type]).to eql(:device) - expect(state[:fstype]).to eq("ranked") - end - - it "returns the device as its identity" do - expect(resource.identity).to eq("charmander") - end - end - - describe "when it has username, password and domain" do - before do - resource.mount_point("T:") - resource.device("charmander") - resource.username("Administrator") - resource.password("Jetstream123!") - resource.domain("TEST_DOMAIN") - end - - it "describes its state" do - state = resource.state_for_resource_reporter - expect(state[:mount_point]).to eq("T:") - expect(state[:username]).to eq("Administrator") - expect(state[:password]).to eq("*sensitive value suppressed*") - expect(state[:domain]).to eq("TEST_DOMAIN") - expect(state[:device_type]).to eql(:device) - expect(state[:fstype]).to eq("auto") - end - - end end |