Using test-kitchen and kitchen-vagrant behind an HTTP proxy

Here’s what got us working with test-kitchen and kitchen-vagrant behind an HTTP proxy. Comments inline.

---
driver:
  name: vagrant
  driver_config:
    # Allows fetching boxes if required
    http_proxy: http://yourproxy.example.com:80
    https_proxy: https://yourproxy.example.com:80
  # This vagrantfiles callout is needed because of
  # https://github.com/test-kitchen/test-kitchen/issues/821
  # You should check that issue to see if this is still required.
  vagrantfiles:
    - your-site-specific-vagrantfile-block.rb
  network:
    - ["private_network", {ip: "192.168.1.2"}]

provisioner:
  name: chef_zero
  # Allows fetching Omnibus Chef installer if required
  http_proxy: http://yourproxy.example.com:80
  https_proxy: http://yourproxy.example.com:80

platforms:
  - name: centos-6.7

suites:
  - name: default
    run_list:
      - recipe[things::default]
    attributes:
      chef-client:
        # Allows your Chef run to fetch stuff it requires
        config:
          http_proxy: "http://yourproxy.example.com:80"
          https_proxy: "http://yourproxy.example.com:80"

And finally your-site-specific-vagrantfile-block.rb, your custom Vagrantfile piece that is merged in via the vagrantfiles directive in your YAML file:

unless Vagrant.has_plugin?("vagrant-proxyconf")
  raise "Missing required plugin 'vagrant-proxyconf', run `vagrant plugin install vagrant-proxyconf`"
end

Vagrant.configure(2) do |config|
  # Allows busser gem and deps to be fetched as required
  config.proxy.http     = "#{ENV['http_proxy']}"
  config.proxy.https    = "#{ENV['https_proxy']}"
  config.proxy.no_proxy = "localhost,127.0.0.1"
end

Leave a Reply

Your email address will not be published. Required fields are marked *