From a11322a7deb425156d5084272cb0b647822131ec Mon Sep 17 00:00:00 2001 From: Phil Nelson Date: Tue, 14 Mar 2017 01:29:44 -0600 Subject: [PATCH] Accommodate missing plugins in kitchen_vagrant_block.rb Prevents Vagrant failures: 'Unknown configuration section '. Also accommodate missing http_proxy environment variable, which will be nil and have no `empty?` method. --- .kitchen.vagrant.yml | 4 ---- kitchen_vagrant_block.rb | 14 +++++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.kitchen.vagrant.yml b/.kitchen.vagrant.yml index a7c8993..4dc2694 100644 --- a/.kitchen.vagrant.yml +++ b/.kitchen.vagrant.yml @@ -23,10 +23,6 @@ provisioner: transport: max_ssh_sessions: 5 -transport: - max_ssh_sessions: 5 - - platforms: - name: ubuntu-12.04 driver_config: diff --git a/kitchen_vagrant_block.rb b/kitchen_vagrant_block.rb index 41930a7..2814cdc 100644 --- a/kitchen_vagrant_block.rb +++ b/kitchen_vagrant_block.rb @@ -1,15 +1,19 @@ # This is a Vagrant block to allow proxy settings to be carried into Kitchen # You need this for all of yum/apt etc. to work! -unless ENV['http_proxy'].empty? || Vagrant.has_plugin?("vagrant-proxyconf") +unless ENV['http_proxy'].nil? || Vagrant.has_plugin?("vagrant-proxyconf") raise "Missing required plugin 'vagrant-proxyconf' to support HTTP(S) proxies, run `vagrant plugin install vagrant-proxyconf`" end Vagrant.configure(2) do |config| - config.proxy.http = "#{ENV['http_proxy']}" - config.proxy.https = "#{ENV['https_proxy']}" - config.proxy.no_proxy = "localhost,127.0.0.1" + if Vagrant.has_plugin?("vagrant-proxyconf") + config.proxy.http = "#{ENV['http_proxy']}" + config.proxy.https = "#{ENV['https_proxy']}" + config.proxy.no_proxy = "localhost,127.0.0.1" + end # You may have vagrant-vbguest plugin installed to keep your images up to date # - but will probably have VBoxAddition build issues with the foreign boxes listed in .kitchen.vagrant.yml - config.vbguest.auto_update = false + if Vagrant.has_plugin?("vagrant-vbguest") + config.vbguest.auto_update = false + end end