0

I am trying to run Test-Kitchen on a Windows 7 box, using Powershell, behind a corporate firewall (I'm following the tutorial at http://kitchen.ci/docs/getting-started/creating-cookbook). When I run:

PS C:\Users\jazzyb\Documents\git-cookbook> kitchen init --driver=kitchen-vagrant

I get

   identical  .kitchen.yml
   identical  chefignore
ERROR:  Could not find a valid gem 'kitchen-vagrant' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ECONNREFUSED: No connection could be made because
the target machine actively refused it. - connect(2) for "api.rubygems.org" port 443 (https://api.rubygems.org/specs.4.8
.gz)
PS C:\Users\jazzyb\Documents\git-cookbook>

Despite the fact I can access that file using Invoke-WebRequest

PS C:\Users\jazzyb\Documents\git-cookbook> Invoke-WebRequest https://api.rubygems.org/specs.4.8.gz


StatusCode        : 200
StatusDescription : OK
Content           : {31, 139, 8, 0...}
RawContent        : HTTP/1.1 200 OK
                    x-amz-id-2: aVuWL3xWz9vwwto0GZE0uAJ4q8o8N+QsIC9QUJmO63mVNxY95pv994RHuQFrdaCCtvADJSaOOfo=
                    x-amz-request-id: CC71B064EACA4126
                    x-amz-version-id: 4Q20EeykLoACN7Ko3b9Bqw1cARiGEbaI
                    x-amz...
Headers           : {[x-amz-id-2, aVuWL3xWz9vwwto0GZE0uAJ4q8o8N+QsIC9QUJmO63mVNxY95pv994RHuQFrdaCCtvADJSaOOfo=],
                    [x-amz-request-id, CC71B064EACA4126], [x-amz-version-id, 4Q20EeykLoACN7Ko3b9Bqw1cARiGEbaI],
                    [x-amz-meta-surrogate-key, full-index]...}
RawContentLength  : 2626893

Setting the proxy directly doesn't seem to work either

PS C:\Users\jazzyb\Documents\git-cookbook> kitchen init --driver=kitchen-vagrant --http_proxy=http://proxy.somecorp.com:80/

Am I missing something obvious?

1 Answers1

1

Export the http_proxy, HTTP_PROXY, https_proxy, and HTTPS_PROXY environment variables. Rubygems doesn't directly supports Windows' proxy configuration system, you need to do it the Unix way.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • If the proxy does SSL interception, exporting `SSL_CERT_FILE` to point to a modified cacert.pem including the proxy certificate should be done too [Related answer](http://stackoverflow.com/a/25605415/3627607) – Tensibai Dec 02 '15 at 08:41
  • Thanks. For any powershell super-newbies like me, I was able to do that via $env:http_proxy="http://proxy.somecorp.com" – Buachaille Etive-Mor Dec 02 '15 at 10:17
  • That fixes it for "kitchen init", but then when I try to run "kitchen create..." which tries to download an Ubuntu box, I get the same kind of issue "Proxy CONNECT aborted". Again, I can manually request the file using Invoke-WebRequest. I've set all 4 proxy values, you suggested – Buachaille Etive-Mor Dec 02 '15 at 10:29
  • You said "box" so I assume you mean Vagrant, you'll want to get https://github.com/tmatilai/vagrant-proxyconf/ and configure it in your kitchen.yml. – coderanger Dec 02 '15 at 16:44
  • Thanks. Unfortunately even installing vagrant-proxy-conf and trying to to add the username and password to the proxy details still doesn't resolve the issue. I'll look into if there's a way to use a local copy of the Ubuntu box or use an existing VirtualBox machine I've created (VirtualBox seems to pick up the proxy settings ok) – Buachaille Etive-Mor Jan 05 '16 at 12:44