Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #186 from tmatilai/install-same-chef-version
Browse files Browse the repository at this point in the history
Default to installing the same Chef version on the node as is used on work station
  • Loading branch information
tmatilai committed Feb 15, 2013
2 parents bc6faec + 2d98821 commit cd71aa8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 5 additions & 2 deletions lib/chef/knife/solo_prepare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ def operating_system
end

def chef_version
v = Chef::Config[:knife][:bootstrap_version]
(v && !v.empty?) ? v : nil
if (v = Chef::Config[:knife][:bootstrap_version])
v.empty? ? nil : v
else
Chef::VERSION
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cases/apache2_bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Apache2Bootstrap

def test_apache2
write_cheffile
assert_subcommand "bootstrap --run-list=recipe[apache2] #{omnibus_options}"
assert_subcommand "bootstrap --run-list=recipe[apache2]"
assert_match default_apache_message, http_response
end
end
13 changes: 12 additions & 1 deletion test/solo_prepare_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ def setup
@host = '[email protected]'
end

def test_uses_local_chef_version_by_default
Chef::Config[:knife][:bootstrap_version] = nil
assert_equal Chef::VERSION, command.chef_version
end

def test_uses_chef_version_from_knife_config
Chef::Config[:knife][:bootstrap_version] = "10.12.2"
assert_match "10.12.2", command.chef_version
assert_equal "10.12.2", command.chef_version
end

def test_uses_chef_version_from_command_line_option
Chef::Config[:knife][:bootstrap_version] = "10.16.2"
assert_equal "0.4.2", command("--bootstrap-version", "0.4.2").chef_version
end

def test_chef_version_returns_nil_if_empty
Chef::Config[:knife][:bootstrap_version] = "10.12.2"
assert_nil command("--bootstrap-version", "").chef_version
end

Expand Down
9 changes: 1 addition & 8 deletions test/support/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,7 @@ def prepare_server

# The prepare command to use on this server
def prepare_command
"prepare #{omnibus_options}"
end

def omnibus_options
return "" if ENV['CHEF_VERSION'].to_s.empty?

v = `knife --version`.split(':')
v[0].strip == 'Chef' ? "--bootstrap-version=#{v[1].strip}" : ''
"prepare"
end

# Provides the path to the runner's key file
Expand Down

0 comments on commit cd71aa8

Please sign in to comment.