Skip to content

Commit

Permalink
add Chef-DK, remove Ruby and Omnnibus Chef installations, update DevK…
Browse files Browse the repository at this point in the history
…it for Chef-DK (x86)
  • Loading branch information
tknerr committed Jun 24, 2014
1 parent a1202fc commit d9f04c9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 78 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
* made it easier to change the mount drive letter ([#57](https://github.com/tknerr/bills-kitchen/issues/57))
* tool updates
* add clink for command autocompletion ([#55](https://github.com/tknerr/bills-kitchen/issues/55))
* update to Ruby (x64) 2.0.0-p481
* update to DevKit (x64) 4.7.2
* update to bundler 1.6.2
* update to Omnibus Chef 11.12.8 (still Ruby 1.9.x)
* remove separate Ruby and Omnibus Chef installations in favor of [Chef-DK](http://www.getchef.com/downloads/chef-dk/windows/)
* Chef-DK embedded Ruby 2.0.0p451 (x86) [is now the primary Ruby](http://jtimberman.housepub.org/blog/2014/04/30/chefdk-and-ruby/)
* update to DevKit 4.7.2 (x86), compatible with Chef-DK Ruby 2.x

# [1.0] from 19/03/2014

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ All you (or Bill Gates would) need for cooking with Chef and Vagrant on Windows,

The main tools for cooking with Chef / Vagrant:

* [Ruby](http://rubyinstaller.org/downloads/) 2.0.0 + [DevKit](http://rubyinstaller.org/add-ons/devkit/) 4.7.2
* [Chef-DK](http://www.getchef.com/downloads/chef-dk/windows/) 0.1.1, with embedded [Ruby](http://rubyinstaller.org/downloads/) 2.0.0
* [DevKit](http://rubyinstaller.org/add-ons/devkit/) 4.7.2
* [Vagrant](http://vagrantup.com/) 1.3.5
* [Omnibus Chef](http://www.getchef.com/chef/install/) 11.12.8

### Plugins

These plugins are pre-installed:

* [bundler](http://bundler.io/) is the only pre-installed gem, use project-specific `Gemfile` for everything else
* [bindler](https://github.com/fgrehm/bindler) is the only pre-installed vagrant plugin, use project-specific `plugins.json` for everyting else
* [knife-audit](https://github.com/jbz/knife-audit) and [knife-server](https://github.com/fnichol/knife-server) are exemplary pre-installed knife plugins. Use `W:/tools/chef/opscode/chef/embedded/bin/gem install <plugin>` to install more

Expand Down
46 changes: 10 additions & 36 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ desc 'downloads required resources and builds the devpack binary'
task :build do
recreate_dirs
download_tools
move_ruby
fix_stuff
fix_chefdk
download_installables
copy_files
generate_docs
install_knife_plugins
install_vagrant_plugins
install_gems
clone_repositories
run_tests "integration"
end
Expand Down Expand Up @@ -131,37 +129,25 @@ def download_tools
%w{ github.com/mridgers/clink/releases/download/0.4.2/clink_0.4.2_setup.exe clink },
%w{ c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.2%20x64.zip sublimetext2 },
%w{ msysgit.googlecode.com/files/PortableGit-1.9.0-preview20140217.7z portablegit },
%w{ dl.bintray.com/oneclick/rubyinstaller/ruby-2.0.0-p481-x64-mingw32.7z ruby },
%w{ cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe devkit },
%w{ cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe devkit },
%w{ switch.dl.sourceforge.net/project/kdiff3/kdiff3/0.9.96/KDiff3Setup_0.9.96.exe kdiff3
kdiff3.exe },
%w{ the.earth.li/~sgtatham/putty/0.63/x86/putty.zip putty },
# %w{ dl.bintray.com/mitchellh/vagrant/Vagrant_1.4.3.msi vagrant },
%w{ files.vagrantup.com/packages/a40522f5fabccb9ddabad03d836e120ff5d14093/Vagrant_1.3.5.msi vagrant },
%w{ opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-windows-11.12.8-2.windows.msi chef},
%w{ chefdk-trial-packages.s3.amazonaws.com/chefdk-0.1.1-20140610201455.msi chef-dk }
]
.each do |host_and_path, target_dir, includes = ''|
download_and_unpack "http://#{host_and_path}", "#{BUILD_DIR}/tools/#{target_dir}", includes.split('|')
end
end

# move ruby to a shorter path to reduce the likeliness that a gem fails to install due to max path length
def move_ruby
FileUtils.mv "#{BUILD_DIR}/tools/ruby/ruby-2.0.0-p481-x64-mingw32", "#{BUILD_DIR}/tools/ruby-2.0.0"
FileUtils.rm_rf "#{BUILD_DIR}/tools/ruby"
end

def fix_stuff
# ensure omnibus chef uses the embedded ruby, see opscode/chef#1512
Dir.glob("#{BUILD_DIR}/tools/chef/opscode/chef/bin/*.bat").each do |file|
File.write(file, File.read(file).gsub('@"ruby.exe" "%~dpn0"', '@"%~dp0\..\embedded\bin\ruby.exe" "%~dpn0"'))
end
# fix paths if chefdk is intalled anywhere other than c:\opscode, see opscode/chef-dk#68
def fix_chefdk
Dir.glob("#{BUILD_DIR}/tools/chef-dk/opscode/chefdk/bin/*").each do |file|
File.write(file, File.read(file).gsub('@"ruby.exe" "%~dpn0"', '@"%~dp0\..\embedded\bin\ruby.exe" "%~dpn0"'))
File.write(file, File.read(file).gsub(/Kernel.load '(.*)'/, "Kernel.load \"\\1\""))
File.write(file, File.read(file).gsub('c:/opscode/chefdk', '#{File.expand_path(File.dirname(__FILE__))}/..'))
# ensure omnibus / chef-dk use the embedded ruby, see opscode/chef#1512
File.write(file, File.read(file).gsub('@"ruby.exe" "%~dpn0"', '@"%~dp0\..\embedded\bin\ruby.exe" "%~dpn0"'))
# fix paths if chefdk is intalled anywhere other than c:\opscode, see opscode/chef-dk#68
File.write(file, File.read(file).gsub(/Kernel.load '(.*)'/, "Kernel.load \"\\1\""))
File.write(file, File.read(file).gsub('c:/opscode/chefdk', '#{File.expand_path(File.dirname(__FILE__))}/..'))
end
end

Expand All @@ -176,10 +162,9 @@ end

def install_knife_plugins
Bundler.with_clean_env do
omnibus_embedded_gem = "#{BUILD_DIR}/tools/chef/opscode/chef/embedded/bin/gem"
command = "#{BUILD_DIR}/set-env.bat \
&& #{omnibus_embedded_gem} install knife-audit -v 0.2.0 --no-ri --no-rdoc \
&& #{omnibus_embedded_gem} install knife-server -v 1.1.0 --no-ri --no-rdoc"
&& chef gem install knife-audit -v 0.2.0 --no-ri --no-rdoc \
&& chef gem install knife-server -v 1.1.0 --no-ri --no-rdoc"
fail "knife plugin installation failed" unless system(command)
end
end
Expand All @@ -193,17 +178,6 @@ def install_vagrant_plugins
end
end

def install_gems
Bundler.with_clean_env do
# XXX: DOH! - with_clean_env does not clear GEM_HOME if the rake task is invoked using `bundle exec`,
# which results in gems being installed to your current Ruby's GEM_HOME rather than Bills Kitchen's GEM_HOME!!!
fail "must run `rake build` instead of `bundle exec rake build`" if ENV['GEM_HOME']
command = "#{BUILD_DIR}/set-env.bat \
&& gem install bundler -v 1.6.2 --no-ri --no-rdoc"
fail "gem installation failed" unless system(command)
end
end

def reset_git_user
Bundler.with_clean_env do
command = "#{BUILD_DIR}/set-env.bat \
Expand Down
13 changes: 9 additions & 4 deletions files/set-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
set SCRIPT_DIR=%~dp0

:: for these we need the bin dirs in PATH
set RUBYDIR=%SCRIPT_DIR%tools\ruby-2.0.0
set DEVKITDIR=%SCRIPT_DIR%tools\devkit
set KDIFF3DIR=%SCRIPT_DIR%tools\kdiff3
set CYGWINSSHDIR=%SCRIPT_DIR%tools\cygwin-ssh
Expand All @@ -17,7 +16,7 @@ set SUBLIMEDIR=%SCRIPT_DIR%tools\sublimetext2
set PUTTYDIR=%SCRIPT_DIR%tools\putty
set CLINKDIR=%SCRIPT_DIR%tools\clink
set VAGRANTDIR=%SCRIPT_DIR%tools\vagrant\HashiCorp\Vagrant
set CHEFDIR=%SCRIPT_DIR%tools\chef\opscode\chef
set CHEFDKDIR=%SCRIPT_DIR%tools\chef-dk\opscode\chefdk

:: inject clink into current cmd.exe
call %CLINKDIR%\clink.bat inject
Expand All @@ -29,6 +28,11 @@ call %DEVKITDIR%\devkitvars.bat
set GITDIR=%SCRIPT_DIR%tools\portablegit
set HOME=%SCRIPT_DIR%home

:: Chef-DK embedded Ruby is now the primary one!
:: see http://jtimberman.housepub.org/blog/2014/04/30/chefdk-and-ruby/
set RUBYDIR=%CHEFDKDIR%\embedded
set GEMDIR=%HOME%\.chefdk\gem\ruby\2.0.0

:: prompt for .gitconfig username/email
FOR /F "usebackq tokens=*" %%a IN (`cmd /C %GITDIR%\cmd\git config --get user.name`) DO SET GIT_CONF_USERNAME=%%a
if "%GIT_CONF_USERNAME%"=="" (
Expand Down Expand Up @@ -69,7 +73,9 @@ set ANSICON=true
set SSL_CERT_FILE=%HOME%\cacert.pem

:: show the environment
echo CHEFDKDIR=%CHEFDKDIR%
echo RUBYDIR=%RUBYDIR%
echo GEMDIR=%GEMDIR%
echo DEVKITDIR=%DEVKITDIR%
echo VBOX_USER_HOME=%VBOX_USER_HOME%
echo VBOX_INSTALL_PATH=%VBOX_INSTALL_PATH%
Expand All @@ -82,7 +88,6 @@ echo PUTTYDIR=%PUTTYDIR%
echo CLINKDIR=%CLINKDIR%
echo VAGRANTDIR=%VAGRANTDIR%
echo VAGRANT_HOME=%VAGRANT_HOME%
echo CHEFDIR=%CHEFDIR%
echo GITDIR=%GITDIR%
echo GIT_CONF_USERNAME=%GIT_CONF_USERNAME%
echo GIT_CONF_EMAIL=%GIT_CONF_EMAIL%
Expand All @@ -92,4 +97,4 @@ echo HTTP_PROXY=%HTTP_PROXY%
@doskey vi=sublime_text $*
@doskey be=bundle exec $*

set PATH=%CHEFDIR%\bin;%VAGRANTDIR%\bin;%RUBYDIR%\bin;%GITDIR%\cmd;%KDIFF3DIR%;%CYGWINRSYNCDIR%;%CYGWINSSHDIR%;%VAGRANTDIR%\embedded\bin;%CONEMUDIR%;%SUBLIMEDIR%;%PUTTYDIR%;%VBOX_INSTALL_PATH%;%PATH%
set PATH=%CHEFDKDIR%\bin;%RUBYDIR%\bin;%GEMDIR%\bin;%VAGRANTDIR%\bin;%GITDIR%\cmd;%KDIFF3DIR%;%CYGWINRSYNCDIR%;%CYGWINSSHDIR%;%VAGRANTDIR%\embedded\bin;%CONEMUDIR%;%SUBLIMEDIR%;%PUTTYDIR%;%VBOX_INSTALL_PATH%;%PATH%
13 changes: 9 additions & 4 deletions files/set-env.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

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

$env:RUBYDIR = Join-Path $pwd tools\ruby-2.0.0
$env:DEVKITDIR = Join-Path $pwd tools\devkit
$env:KDIFF3DIR = Join-Path $pwd tools\kdiff3
$env:CYGWINSSHDIR = Join-Path $pwd tools\cygwin-ssh
Expand All @@ -11,7 +10,7 @@ $env:SUBLIMEDIR = Join-Path $pwd tools\sublimetext2
$env:PUTTYDIR = Join-Path $pwd tools\putty
$env:CLINKDIR = Join-Path $pwd tools\clink
$env:VAGRANTDIR = Join-Path $pwd tools\vagrant\HashiCorp\Vagrant
$env:CHEFDIR = Join-Path $pwd tools\chef\opscode\chef
$env:CHEFDKDIR = Join-Path $pwd tools\chef-dk\opscode\chefdk

## inject clink into current cmd.exe
invoke-expression ((Join-Path $env:CLINKDIR clink.bat) inject)
Expand All @@ -21,6 +20,11 @@ invoke-expression (Join-Path $env:DEVKITDIR devkitvars.bat)

$env:HOME = Join-Path $pwd home

## Chef-DK embedded Ruby is now the primary one!
## see http://jtimberman.housepub.org/blog/2014/04/30/chefdk-and-ruby/
$env:RUBYDIR = Join-Path $env:CHEFDKDIR embedded
$env:GEMDIR = Join-Path $env:HOME .chefdk\gem\ruby\2.0.0

if($env:GITDIR -eq $NULL) {
$env:GITDIR = Join-Path $pwd tools\portablegit
$env:Path = "$env:Path;$(Join-Path $env:GITDIR "cmd")"
Expand Down Expand Up @@ -75,7 +79,9 @@ $env:ANSICON = "true"
$env:SSL_CERT_FILE = Join-Path $env:HOME "cacert.pem"

# show the environment
Write-Host "CHEFDKDIR=$env:CHEFDKDIR"
Write-Host "RUBYDIR=$env:RUBYDIR"
Write-Host "GEMDIR=$env:GEMDIR"
Write-Host "DEVKITDIR=$env:DEVKITDIR"
Write-Host "VBOX_USER_HOME=$env:VBOX_USER_HOME"
Write-Host "VBOX_INSTALL_PATH=$env:VBOX_INSTALL_PATH"
Expand All @@ -88,7 +94,6 @@ Write-Host "PUTTYDIR=$env:PUTTYDIR"
Write-Host "CLINKDIR=$env:CLINKDIR"
Write-Host "VAGRANTDIR=$env:VAGRANTDIR"
Write-Host "VAGRANT_HOME=$env:VAGRANT_HOME"
Write-Host "CHEFDIR=$env:CHEFDIR"
Write-Host "GITDIR=$env:GITDIR"
Write-Host "GIT_CONF_USERNAME=$env:GIT_CONF_USERNAME"
Write-Host "GIT_CONF_EMAIL=$env:GIT_CONF_EMAIL"
Expand All @@ -97,4 +102,4 @@ Write-Host "HTTP_PROXY=$env:HTTP_PROXY"
set-alias vi "sublime_text";
set-alias be "bundle exec";

$env:Path = "$env:CHEFDIR\bin;$env:VAGRANTDIR\bin;$env:RUBYDIR\bin;$env:KDIFF3DIR;$env:CYGWINRSYNCDIR;$env:CYGWINSSHDIR;$env:VAGRANTDIR\embedded\bin;$env:CONEMUDIR;$env:SUBLIMEDIR;$env:PUTTYDIR;$env:VBOX_INSTALL_PATH;$env:Path"
$env:Path = "$env:CHEFDKDIR\bin;$env:RUBYDIR\bin;$env:GEMDIR\bin;$env:VAGRANTDIR\bin;$env:KDIFF3DIR;$env:CYGWINRSYNCDIR;$env:CYGWINSSHDIR;$env:VAGRANTDIR\embedded\bin;$env:CONEMUDIR;$env:SUBLIMEDIR;$env:PUTTYDIR;$env:VBOX_INSTALL_PATH;$env:Path"
11 changes: 5 additions & 6 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

BUILD_DIR=File.expand_path('./target/build')
LOGFILE = "#{BUILD_DIR}/acceptance.log"
SYSTEM_RUBY = "#{BUILD_DIR}/tools/ruby-2.0.0"
OMNIBUS_RUBY = "#{BUILD_DIR}/tools/chef/opscode/chef/embedded"
CHEFDK_RUBY = "#{BUILD_DIR}/tools/chef-dk/opscode/chefdk/embedded"
VAGRANT_RUBY = "#{BUILD_DIR}/tools/vagrant/HashiCorp/Vagrant/embedded"

# enable :should syntax for rspec 3
Expand Down Expand Up @@ -39,13 +38,13 @@ def cmd_succeeds(cmd)
def env_match(line)
run_cmd("set").should match(/^#{convert_slashes(line)}$/)
end
# checks if the given gem is installed at version
def gem_installed(name, version, gem_cmd = "#{SYSTEM_RUBY}/bin/gem")
run_cmd("#{gem_cmd} list").should match("#{name} \\(#{version}\\)")
# checks if the given gem is installed at version in the CHEFDK_RUBY
def gem_installed(name, version)
run_cmd("#{CHEFDK_RUBY}/bin/gem list").should match("#{name} \\(#{version}\\)")
end
# checks if the given gem is installed at version
def knife_plugin_installed(name, version)
gem_installed name, version, "#{OMNIBUS_RUBY}/bin/gem"
gem_installed name, version
end
# checks if the given gem is installed at version
def vagrant_plugin_installed(name, version)
Expand Down
36 changes: 15 additions & 21 deletions spec/integration/bills_kitchen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
include Helpers

describe "tools" do
it "installs Ruby 2.0.0p481" do
run_cmd("ruby -v").should match('2.0.0p481')
end
it "installs RubyGems 2.0.14" do
run_cmd("gem -v").should match("2.0.14")
end
it "installs Chef 11.12.8" do
run_cmd("knife -v").should match('Chef: 11.12.8')
it "installs Chef-DK 0.1.1" do
run_cmd("chef -v").should match('Chef Development Kit Version: 0.1.1')
end
it "installs Vagrant 1.3.5" do
run_cmd("vagrant -v").should match('1.3.5')
Expand Down Expand Up @@ -73,24 +67,24 @@

describe "ruby installations" do

describe "system ruby" do
describe "chefdk as the primary ruby" do
it "provides the default `ruby` command" do
run_cmd("which ruby").should match(convert_slashes("#{SYSTEM_RUBY}/bin/ruby.EXE"))
run_cmd("which ruby").should match(convert_slashes("#{CHEFDK_RUBY}/bin/ruby.EXE"))
end
it "provides the default `gem` command" do
run_cmd("which gem").should match(convert_slashes("#{SYSTEM_RUBY}/bin/gem"))
end
it "uses the system ruby gemdir" do
run_cmd("#{SYSTEM_RUBY}/bin/gem environment gemdir").should match("#{SYSTEM_RUBY}/lib/ruby/gems/2.0.0")
end
it "has 'bundler (1.6.2)' gem installed" do
gem_installed "bundler", "1.6.2"
run_cmd("which gem").should match(convert_slashes("#{CHEFDK_RUBY}/bin/gem"))
end
end

describe "omnibus ruby" do
it "uses the omnibus embedded gemdir" do
run_cmd("#{OMNIBUS_RUBY}/bin/gem environment gemdir").should match("#{OMNIBUS_RUBY}/lib/ruby/gems/1.9.1")
describe "chefdk ruby" do
it "installs Chef 11.14.0.alpha.5" do
run_cmd("knife -v").should match('Chef: 11.14.0.alpha.5')
end
it "uses the chef-dk embedded gemdir" do
run_cmd("#{CHEFDK_RUBY}/bin/gem environment gemdir").should match("#{CHEFDK_RUBY}/lib/ruby/gems/2.0.0")
end
it "has 'bundler (1.5.2)' gem installed" do
gem_installed "bundler", "1.5.2"
end
it "has 'knife-audit (0.2.0)' plugin installed" do
knife_plugin_installed "knife-audit", "0.2.0"
Expand All @@ -102,7 +96,7 @@

describe "vagrant ruby" do
it "uses the vagrant embedded gemdir" do
run_cmd("#{VAGRANT_RUBY}/bin/gem environment gemdir").should match("#{VAGRANT_RUBY}/lib/ruby/gems/1.9.1")
run_cmd("#{VAGRANT_RUBY}/bin/gem environment gemdir").should match("#{VAGRANT_RUBY}/lib/ruby/gems/1.9.1")
end
it "has 'bindler (0.1.3)' plugin installed" do
vagrant_plugin_installed "bindler", "0.1.3"
Expand Down

0 comments on commit d9f04c9

Please sign in to comment.