Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Proxy Support #102

Merged
merged 11 commits into from
May 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* make the `b2d-start.bat` and `b2d-stop.bat` scripts more resilient
* add `b2d` shortcut doskey alias for `boot2docker`
* add `GLOBAL_VAGRANT_CACHIER_DISABLED` env var to allow for disabling vagrant-cachier in the global Vagrantfile ([#98](https://github.com/tknerr/bills-kitchen/pull/98))
* patch vagrant with remote docker host support; conditionally enable it `b2d-start` and disable it in `b2d-stop` (experimental, see [#100](https://github.com/tknerr/bills-kitchen/pull/100git))
* patch vagrant with remote docker host support; conditionally enable it `b2d-start` and disable it in `b2d-stop` (experimental, see [#100](https://github.com/tknerr/bills-kitchen/pull/100git))
* add `proxy-on.bat` and `proxy-off.bat` convenience scripts for setting the proxy env vars (see [#102](https://github.com/tknerr/bills-kitchen/pull/102))
* add the [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf) plugin for configuring the proxy inside vagrant VMs (see [#102](https://github.com/tknerr/bills-kitchen/pull/102))
* bug fixes:
* make `bundle` and other gem binaries work in `git-bash` too [#97](https://github.com/tknerr/bills-kitchen/issues/97)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ These plugins are pre-installed:
* [vagrant-cachier](https://github.com/fgrehm/vagrant-cachier) - caches all kinds of packages you intsall in the vagrant VMs
* [vagrant-berkshelf](https://github.com/berkshelf/vagrant-berkshelf) - berkshelf integration for vagrant
* [vagrant-toplevel-cookbooks](https://github.com/tknerr/vagrant-toplevel-cookbooks) - support for one top-level cookbook per vagrant VM
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf) - for configuring a proxy inside the VMs
* ...use `vagrant install <plugin>` to install more
* knife plugins (just as an example):
* [knife-audit](https://github.com/jbz/knife-audit) - keeps track of which cookbooks are used by which node
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def install_vagrant_plugins
&& vagrant plugin install vagrant-toplevel-cookbooks --plugin-version 0.2.4 \
&& vagrant plugin install vagrant-omnibus --plugin-version 1.4.1 \
&& vagrant plugin install vagrant-cachier --plugin-version 1.2.0 \
&& vagrant plugin install vagrant-proxyconf --plugin-version 1.5.0 \
&& vagrant plugin install vagrant-berkshelf --plugin-version 4.0.3"
fail "vagrant plugin installation failed" unless system(command)
end
Expand Down
13 changes: 4 additions & 9 deletions files/set-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
:: # Setting up Environment...
:: ########################################################

set SCRIPT_DIR=%~dp0
set BK_ROOT=%SCRIPT_DIR%
set BK_ROOT=%~dp0

:: for these we need the bin dirs in PATH
set SCRIPTSDIR=%BK_ROOT%tools\scripts
set DOCKERDIR=%BK_ROOT%tools\docker
set DEVKITDIR=%BK_ROOT%tools\devkit
set KDIFF3DIR=%BK_ROOT%tools\kdiff3
Expand Down Expand Up @@ -71,12 +71,6 @@ if "%GIT_CONF_EMAIL%"=="" (
cmd /C %GITDIR%\cmd\git config --global --replace user.name "%GIT_CONF_USERNAME%"
cmd /C %GITDIR%\cmd\git config --global --replace user.email "%GIT_CONF_EMAIL%"

:: toggle proxy based on env var
if "%HTTP_PROXY%"=="" (
cmd /C %GITDIR%\cmd\git config --global --unset http.proxy
) else (
cmd /C %GITDIR%\cmd\git config --global --replace http.proxy %HTTP_PROXY%
)

:: don't let VirtualBox use %HOME% instead of %USERPROFILE%,
:: otherwise it would become confused when W:\ is unmounted
Expand All @@ -103,6 +97,7 @@ set CYGWIN=nodosfilewarning
:: show the environment
echo BK_ROOT=%BK_ROOT%
echo HOME=%HOME%
echo SCRIPTSDIR=%SCRIPTSDIR%
echo CHEFDKDIR=%CHEFDKDIR%
echo CHEFDKHOMEDIR=%CHEFDKHOMEDIR%
echo GEM_ROOT=%GEM_ROOT%
Expand Down Expand Up @@ -136,4 +131,4 @@ echo HTTP_PROXY=%HTTP_PROXY%
@doskey be=bundle exec $*
@doskey b2d=boot2docker $*

set PATH=%DOCKERDIR%;%CHEFDK_PATH_ENTRIES%;%CONSULDIR%;%PACKERDIR%;%TERRAFORMDIR%;%VAGRANTDIR%\bin;%GITDIR%\cmd;%GITDIR%;%KDIFF3DIR%;%CWRSYNCDIR%;%VAGRANTDIR%\embedded\bin;%CONEMUDIR%;%ATOMDIR%;%APMDIR%;%PUTTYDIR%;%VBOX_MSI_INSTALL_PATH%;%VBOX_INSTALL_PATH%;%PATH%
set PATH=%SCRIPTSDIR%;%DOCKERDIR%;%CHEFDK_PATH_ENTRIES%;%CONSULDIR%;%PACKERDIR%;%TERRAFORMDIR%;%VAGRANTDIR%\bin;%GITDIR%\cmd;%GITDIR%;%KDIFF3DIR%;%CWRSYNCDIR%;%VAGRANTDIR%\embedded\bin;%CONEMUDIR%;%ATOMDIR%;%APMDIR%;%PUTTYDIR%;%VBOX_MSI_INSTALL_PATH%;%VBOX_INSTALL_PATH%;%PATH%
7 changes: 4 additions & 3 deletions files/set-env.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

$script:pwd = Split-Path $MyInvocation.MyCommand.Path
$env:BK_ROOT = $pwd
$env:BK_ROOT = Split-Path $MyInvocation.MyCommand.Path

$env:SCRIPTSDIR = Join-Path $env:BK_ROOT tools\scripts
$env:DOCKERDIR = Join-Path $env:BK_ROOT tools\docker
$env:DEVKITDIR = Join-Path $env:BK_ROOT tools\devkit
$env:KDIFF3DIR = Join-Path $env:BK_ROOT tools\kdiff3
Expand Down Expand Up @@ -106,6 +106,7 @@ $env:SSL_CERT_FILE = Join-Path $env:HOME "cacert.pem"
# show the environment
Write-Host "BK_ROOT=$env:BK_ROOT"
Write-Host "HOME=$env:HOME"
Write-Host "SCRIPTSDIR=$env:SCRIPTSDIR"
Write-Host "CHEFDKDIR=$env:CHEFDKDIR"
Write-Host "RUBYDIR=$env:RUBYDIR"
Write-Host "CHEFDKHOMEDIR=$env:CHEFDKHOMEDIR"
Expand Down Expand Up @@ -138,4 +139,4 @@ set-alias vi "atom.cmd";
set-alias be "bundle exec";
set-alias b2d "boot2docker";

$env:Path = "$env:DOCKERDIR;$env:CHEFDK_PATH_ENTRIES;$env:CONSULDIR;$env:PACKERDIR;$env:TERRAFORMDIR;$env:VAGRANTDIR\bin;$env:KDIFF3DIR;$env:CWRSYNCDIR;$env:VAGRANTDIR\embedded\bin;$env:CONEMUDIR;$env:ATOMDIR;$env:APMDIR;$env:PUTTYDIR;$env:VBOX_INSTALL_PATH;$env:Path"
$env:Path = "$env:SCRIPTSDIR;$env:DOCKERDIR;$env:CHEFDK_PATH_ENTRIES;$env:CONSULDIR;$env:PACKERDIR;$env:TERRAFORMDIR;$env:VAGRANTDIR\bin;$env:KDIFF3DIR;$env:CWRSYNCDIR;$env:VAGRANTDIR\embedded\bin;$env:CONEMUDIR;$env:ATOMDIR;$env:APMDIR;$env:PUTTYDIR;$env:VBOX_INSTALL_PATH;$env:Path"
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ boot2docker up
echo Mounting the shared folder inside the VM to %BK_ROOT_CYGPATH%
boot2docker ssh -- sudo mount -t vboxsf billskitchen %BK_ROOT_CYGPATH%

:: for proxies:
:: see http://stackoverflow.com/a/29303930/2388971
:: set / unset proxy in boot2docker VM
:: for more on proxies, see http://stackoverflow.com/a/29303930/2388971
if "%BK_USE_PROXY%" == "1" (
echo setting proxy in the boot2docker VM...
boot2docker ssh "echo 'export HTTP_PROXY=%HTTP_PROXY%; export HTTPS_PROXY=%HTTPS_PROXY%; export NO_PROXY=%NO_PROXY%;' | sudo tee /var/lib/boot2docker/profile"
) else (
echo making sure no proxy is set in the boot2docker VM...
boot2docker ssh "sudo rm -rf /var/lib/boot2docker/profile"
)
boot2docker ssh "sudo /etc/init.d/docker restart > /dev/null"


ENDLOCAL

Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions files/tools/scripts/proxy-off.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

@echo off

:: remove the indicator
set BK_USE_PROXY=

:: unset the proxy on the host system
set HTTP_PROXY=
set HTTPS_PROXY=
set NO_PROXY=

:: unset reusing the host proxy in vagrant VMs
set VAGRANT_HTTP_PROXY=
set VAGRANT_HTTPS_PROXY=
set VAGRANT_NO_PROXY=
22 changes: 22 additions & 0 deletions files/tools/scripts/proxy-on.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

@echo off

:: indicate that a proxy should be used
set BK_USE_PROXY=1

:: set the proxy on the host system
set HTTP_PROXY=http://[your.proxy]:[port]
set HTTPS_PROXY=https://[your.proxy]:[port]
set NO_PROXY=localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16

:: reuse the host proxy in vagrant VMs
set VAGRANT_HTTP_PROXY=%HTTP_PROXY%
set VAGRANT_HTTPS_PROXY=%HTTPS_PROXY%
set VAGRANT_NO_PROXY=%NO_PROXY%


:: better check :-)
if "%HTTP_PROXY%" == "http://[your.proxy]:[port]" (
echo oops - did you forget to configure the proxy in %~df0?
exit /b 1
)
3 changes: 3 additions & 0 deletions spec/integration/bills_kitchen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
it "has 'vagrant-cachier (1.2.0)' plugin installed" do
vagrant_plugin_installed "vagrant-cachier", "1.2.0"
end
it "has 'vagrant-proxyconf (1.5.0)' plugin installed" do
vagrant_plugin_installed "vagrant-proxyconf", "1.5.0"
end
it "has 'vagrant-berkshelf (4.0.3)' plugin installed" do
vagrant_plugin_installed "vagrant-berkshelf", "4.0.3"
end
Expand Down