diff options
author | sanga17 <sausekar@msystechnologies.com> | 2020-06-02 18:09:46 +0530 |
---|---|---|
committer | sanga17 <sausekar@msystechnologies.com> | 2020-06-02 18:16:39 +0530 |
commit | 8a615e7f1c0486670bf990b3985ae4eef25fb2b1 (patch) | |
tree | f136f857cbf7c98ab796eb8040babf0fc21d1feb /lib | |
parent | cb57400ec0048a162909875b769b7366cdd30204 (diff) | |
download | chef-8a615e7f1c0486670bf990b3985ae4eef25fb2b1.tar.gz |
Fixed Powershell_Package does not throw error when it cannot connect to powershell gallery
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/powershell.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb index 20317e41f1..51cb387cad 100644 --- a/lib/chef/provider/package/powershell.rb +++ b/lib/chef/provider/package/powershell.rb @@ -53,6 +53,9 @@ class Chef # Installs the package specified with the version passed else latest version will be installed def install_package(names, versions) + # To enable tls 1.2, which is disabled by default in some OS + powershell_out("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12") + names.each_with_index do |name, index| cmd = powershell_out(build_powershell_package_command("Install-Package '#{name}'", versions[index]), timeout: new_resource.timeout) next if cmd.nil? @@ -115,7 +118,8 @@ class Chef command = [command] unless command.is_a?(Array) cmdlet_name = command.first command.unshift("(") - %w{-Force -ForceBootstrap}.each do |arg| + # -WarningAction SilentlyContinue is used to suppress the warnings from stdout + %w{-Force -ForceBootstrap -WarningAction SilentlyContinue}.each do |arg| command.push(arg) end command.push("-RequiredVersion #{version}") if version |