When using kitchen on MacOS and WindowsServer 2012 as my target test box I get errors when Chef is trying to download remote resources. It doesn't matter if it's an internal or external resource, they both fail.
The weird thing is that if I use the same URL that Chef is trying to use that URL works through both the browser and PowerShell via 'iwr' on the target VM.
Chef error:
[2017-03-07T08:02:20-08:00] ERROR: Error connecting to https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.exe, retry 1/5
That URL works fine when ran with both iwr and pasting it into the address bar in a browser.

Final error from kitchen converge:
[2017-03-07T08:04:38-08:00] FATAL: Errno::ECONNRESET: windows_package[Notepad++] (notepadpp::default line 27) had an error: Errno::ECONNRESET: remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache\package\npp.7.Installer.exe] (dynamically defined) had an error: Errno::ECONNRESET: Error connecting to https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.exe - An existing connection was forcibly closed by the remote host.
Host:
MacOS 10.12.3
Chef DK 1.2.22
Guest:
VirtualBox 5.1.8 r111374
Boxes:
opentable/win-2012r2-standard-amd64-nocm
mwrock/Windows2012R2
That is odd. The primary difference is chef is going through ruby which is using its own HTTP stack and also using openssl for cert activity. I’m wondering if you have any proxy config settings in tour .kitchen.yml
that might be causing chef’s http calls to go through a proxy when it really should not be. Do you mind sharing your .kitchen.yml
?
driver:
name: vagrant
customize:
cpus: 2
memory: 4096
transport:
name: winrm
elevated: true
provisioner:
name: chef_zero
deprecations_as_errors: false
verifier:
name: inspec
platforms:
- name: windows-2012r2-chef-12.1
driver_config:
box: mwrock/Windows2012R2
- name: windows-2012r2-ot
driver_config:
box: opentable/win-2012r2-standard-amd64-nocm
suites:
- name: default
run_list:
- recipe[ic-elasticsearch::quick]
Yeah nothing in there looks suspect. Any different result based on which vagrant box you use (mine or opentable)? Have you tried converging again after succesfully hitting those URLS in the browser? Or maybe tried on a different network? These are kind of shots in the dark but I don’t have many other ideas.
I also get a zero-length file when I try and download using just Ruby code
require 'net/http'
# Must be somedomain.net instead of somedomain.net/, otherwise, it will throw exception.
Net::HTTP.start("notepad-plus-plus.org") do |http|
resp = http.get("/repository/7.x/7.0/npp.7.Installer.exe")
open("c:/users/vagrant/npp.7.Installer.exe", "wb") do |file|
file.write(resp.body)
end
end
puts "Done."
Both your and Opentable’s vagrant boxes exhibit this behavior. I try converging multiple times after downloading either using the script above, through a browser, or through ‘iwr’ in Powershell.
Using the code above I was able to pull something from my local Artifactory repo since it’s HTTP, although the same link still fails when run from Chef.
I think the notepad++ url can be http too. Can you try having chef use an http endpoint and see if that works?
Same error:
[2017-03-07T10:35:10-08:00] ERROR: Error connecting to http://notepad-plus-plus.org/repository/7.x/7.2.1/npp.7.2.1.Installer.exe, retry 1/5
So after adding the following to the kitchen.yml to get a bridged connection I can download the npp public resources but I’m still stuck on downloading from our Artifactory instance:
driver:
...
network:
- ["public_network", bridge: "en4: Thunderbolt Ethernet"]
Now I’m going to test using the maven cookbook for getting resources from Artifactory.
So it looks like the NAT’ing on a Mac with Virtualbox is problematic at work, for me anyways.
I am having exact same error while running (on mac) test-kitchen with vagrant (virtualbox) on mwrock/Windows2012R2 box. remote file resource fails to load, however you can download file by directly accessing it from browser / powershell.
I am just copying Vagrantfile and logs here for reference.
Vagrantfile
—
driver:
name: vagrant
network:
- [“public_network”, bridge: “en0: Wi-Fi (AirPort)”]
provisioner:
name: chef_solo
platforms:
- name: mwrock/Windows2012R2
transport:
name: winrm
suites:
- name: default
run_list:
- recipe[ntp::default]
attributes: {
ntp: {
servers: ['0.amazon.pool.ntp.org', '1.amazon.pool.ntp.org', '2.amazon.pool.ntp.org', '3.amazon.pool.ntp.org'],
package_url: 'https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe'
}
}
Logs
-----> Starting Kitchen (v1.16.0)
-----> Converging <default-mwrock-Windows2012R2>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 5.6.4...
Removing non-cookbook files before transfer
Preparing solo.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-mwrock-Windows2012R2>
Starting Chef Client, version 13.0.118
resolving cookbooks for run list: ["ntp::default"]
Synchronizing Cookbooks:
- ntp (3.4.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 7 resources
Recipe: ntp::windows_client
* directory[C:/NTP/etc] action create (up to date)
* cookbook_file[C:/NTP/ntp.ini] action create (up to date)
* remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe] action create[2017-05-18T13:17:21+00:00] ERROR: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe, retry 1/5
[2017-05-18T13:17:26+00:00] ERROR: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe, retry 2/5
[2017-05-18T13:17:31+00:00] ERROR: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe, retry 3/5
[2017-05-18T13:17:35+00:00] ERROR: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe, retry 4/5
[2017-05-18T13:17:40+00:00] ERROR: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe, retry 5/5
================================================================================
Error executing action `create` on resource 'remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe]'
================================================================================
Errno::ECONNRESET
-----------------
Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe - An existing connection was forcibly closed by the remote host.
Resource Declaration:
---------------------
# In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ntp/recipes/windows_client.rb
37: remote_file "#{Chef::Config[:file_cache_path]}/ntpd.exe" do
38: source node['ntp']['package_url']
39: end
40:
Compiled Resource:
------------------
# Declared in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ntp/recipes/windows_client.rb:37:in `from_file'
remote_file("C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe") do
provider Chef::Provider::RemoteFile
action [:create]
default_guard_interpreter :default
source ["https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe"]
use_etag true
use_last_modified true
declared_type :remote_file
cookbook_name "ntp"
recipe_name "windows_client"
path "C:\\Users\\vagrant\\AppData\\Local\\Temp\\kitchen\\cache/ntpd.exe"
checksum nil
rights nil
deny_rights nil
verifications []
end
System Info:
------------
chef_version=13.0.118
platform=windows
platform_version=6.3.9600
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-solo
executable=C:/opscode/chef/bin/chef-solo
Running handlers:
[2017-05-18T13:17:45+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-05-18T13:17:45+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 28 seconds
[2017-05-18T13:17:45+00:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
[2017-05-18T13:17:45+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-05-18T13:17:45+00:00] FATAL: Errno::ECONNRESET: remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe] (ntp::windows_client line 37) had an error: Errno::ECONNRESET: Error connecting to https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p5-win32-setup.exe - An existing connection was forcibly closed by the remote host.
------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
Converge failed on instance <default-mwrock-Windows2012R2>. Please see .kitchen/logs/default-mwrock-Windows2012R2.log for more details
----------------------
Please see .kitchen/logs/kitchen.log for more details
Also try running `kitchen diagnose --all` for configuration