diff options
-rw-r--r-- | lib/chef/provider/package/cab.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/msu.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/msu_package.rb | 5 | ||||
-rw-r--r-- | spec/functional/resource/msu_package_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource/msu_package_spec.rb | 4 |
5 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/provider/package/cab.rb b/lib/chef/provider/package/cab.rb index 7a5dba68e5..3ede6dbe10 100644 --- a/lib/chef/provider/package/cab.rb +++ b/lib/chef/provider/package/cab.rb @@ -74,7 +74,7 @@ class Chef def dism_command(command) with_os_architecture(nil) do - result = shell_out("dism.exe /Online /English #{command} /NoRestart", { timeout: new_resource.timeout || 3600 }) + result = shell_out("dism.exe /Online /English #{command} /NoRestart", { timeout: new_resource.timeout }) if result.exitstatus == -2146498530 raise Chef::Exceptions::Package, "The specified package is not applicable to this image." if result.stdout.include?("0x800f081e") diff --git a/lib/chef/provider/package/msu.rb b/lib/chef/provider/package/msu.rb index 2c67e36e06..a8a8da858a 100644 --- a/lib/chef/provider/package/msu.rb +++ b/lib/chef/provider/package/msu.rb @@ -110,6 +110,7 @@ class Chef @cab_files.each do |cab_file| declare_resource(:cab_package, new_resource.name) do source cab_file + timeout new_resource.timeout action :install end end diff --git a/lib/chef/resource/msu_package.rb b/lib/chef/resource/msu_package.rb index c801cdd971..d07d7893a3 100644 --- a/lib/chef/resource/msu_package.rb +++ b/lib/chef/resource/msu_package.rb @@ -44,6 +44,11 @@ class Chef property :checksum, String, desired_state: false, description: "SHA-256 digest used to verify the checksum of the downloaded MSU package." + + property :timeout, [String, Integer], + default: 3600, + description: "The amount of time (in seconds) to wait before timing out.", + desired_state: false end end end diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb index c49fe9499d..1161049571 100644 --- a/spec/functional/resource/msu_package_spec.rb +++ b/spec/functional/resource/msu_package_spec.rb @@ -24,6 +24,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do let(:package_name) { "Package_for_KB2959977" } let(:package_source) { "https://download.microsoft.com/download/3/B/3/3B320C07-B7B1-41E5-81F4-79EBC02DF7D3/Windows8.1-KB2959977-x64.msu" } let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" } + let(:timeout) { 3600 } let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") } let(:cab_provider) do @@ -37,6 +38,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do new_resource = Chef::Resource::MsuPackage.new("test msu package", run_context) new_resource.package_name package_name new_resource.source package_source + new_resource.timeout timeout new_resource end diff --git a/spec/unit/resource/msu_package_spec.rb b/spec/unit/resource/msu_package_spec.rb index 49fe61b7b9..3c7462a1a7 100644 --- a/spec/unit/resource/msu_package_spec.rb +++ b/spec/unit/resource/msu_package_spec.rb @@ -60,4 +60,8 @@ describe Chef::Resource::MsuPackage do resource.source("package.msu") expect(resource.source).not_to eq("package.msu") end + + it "sets timeout property to 3600 by default" do + expect(resource.timeout).to eql(3600) + end end |