diff options
author | Jason Field <jason.field@calastone.com> | 2019-02-22 13:13:41 +0000 |
---|---|---|
committer | Jason Field <jason.field@calastone.com> | 2019-02-22 13:13:41 +0000 |
commit | ea53a79c9fb0a44f099c789ef61878a6a905e24e (patch) | |
tree | ff5ff6404614ea1c9e9a6a9f123ea777190ebb8f | |
parent | 22e195ac758c4a11af903a8e2d6af6c81bc11319 (diff) | |
download | chef-ea53a79c9fb0a44f099c789ef61878a6a905e24e.tar.gz |
Update Share Bug Fix
Fixes issue where updating a share will cause the share to be deleted
but not re-created until chef is next run, and for chef to fail the run
Signed-off-by: Jason Field <jason@avon-lea.co.uk>
-rw-r--r-- | lib/chef/resource/windows_share.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/chef/resource/windows_share.rb b/lib/chef/resource/windows_share.rb index f0df68927f..76c10e83c3 100644 --- a/lib/chef/resource/windows_share.rb +++ b/lib/chef/resource/windows_share.rb @@ -183,10 +183,12 @@ class Chef converge_if_changed do # you can't actually change the path so you have to delete the old share first - delete_share if different_path? - - # powershell cmdlet for create is different than updates - if current_resource.nil? + if different_path? + Chef::Log.debug('The path has changed so we will delete and recreate share') + delete_share + create_share + elsif current_resource.nil? + # powershell cmdlet for create is different than updates Chef::Log.debug("The current resource is nil so we will create a new share") create_share else @@ -214,7 +216,7 @@ class Chef action_class do def different_path? return false if current_resource.nil? # going from nil to something isn't different for our concerns - return false if current_resource.path == new_resource.path + return false if current_resource.path == Chef::Util::PathHelper.cleanpath(new_resource.path) true end @@ -235,7 +237,7 @@ class Chef def create_share raise "#{new_resource.path} is missing or not a directory. Shares cannot be created if the path doesn't first exist." unless ::File.directory? new_resource.path - share_cmd = "New-SmbShare -Name '#{new_resource.share_name}' -Path '#{new_resource.path}' -Description '#{new_resource.description}' -ConcurrentUserLimit #{new_resource.concurrent_user_limit} -CATimeout #{new_resource.ca_timeout} -EncryptData:#{bool_string(new_resource.encrypt_data)} -ContinuouslyAvailable:#{bool_string(new_resource.continuously_available)}" + share_cmd = "New-SmbShare -Name '#{new_resource.share_name}' -Path '#{Chef::Util::PathHelper.cleanpath(new_resource.path)}' -Description '#{new_resource.description}' -ConcurrentUserLimit #{new_resource.concurrent_user_limit} -CATimeout #{new_resource.ca_timeout} -EncryptData:#{bool_string(new_resource.encrypt_data)} -ContinuouslyAvailable:#{bool_string(new_resource.continuously_available)}" share_cmd << " -ScopeName #{new_resource.scope_name}" unless new_resource.scope_name == "*" # passing * causes the command to fail share_cmd << " -Temporary:#{bool_string(new_resource.temporary)}" if new_resource.temporary # only set true |